-- 加价模式：百分比 / 固定金额
ALTER TABLE `markup_config`
  ADD COLUMN `markup_type` VARCHAR(16) NOT NULL DEFAULT 'percent' AFTER `customer_id`,
  ADD COLUMN `markup_fixed_amount` DECIMAL(12, 2) NULL AFTER `markup_percent`;

ALTER TABLE `markup_config` DROP CHECK `chk_markup`;

ALTER TABLE `markup_config`
  ADD CONSTRAINT `chk_markup_percent` CHECK (
    `markup_type` <> 'percent'
    OR (`markup_percent` >= 0 AND `markup_percent` <= 30.0)
  );

ALTER TABLE `markup_config`
  ADD CONSTRAINT `chk_markup_fixed` CHECK (
    `markup_type` <> 'fixed'
    OR (
      `markup_fixed_amount` IS NOT NULL
      AND `markup_fixed_amount` >= 0
      AND `markup_fixed_amount` <= 99999.99
    )
  );
