-- liquibase formatted sql
-- changeset KelvinY:20260611_02_add_do_replenishment_reason
-- preconditions onFail:MARK_RAN
-- precondition-sql-check expectedResult:1 SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'do_replenishment'

SET @col_dr_reason := (
    SELECT COUNT(*) FROM information_schema.columns
    WHERE table_schema = DATABASE() AND table_name = 'do_replenishment' AND column_name = 'reason'
);
SET @sql_dr_reason := IF(
    @col_dr_reason = 0,
    'ALTER TABLE `do_replenishment` ADD COLUMN `reason` VARCHAR(500) NULL DEFAULT NULL AFTER `status`',
    'SELECT 1'
);
PREPARE stmt_dr_reason FROM @sql_dr_reason;
EXECUTE stmt_dr_reason;
DEALLOCATE PREPARE stmt_dr_reason;
