-- S0-PRIORITYCODE-CUSTOMER-ORDER-TYPE-CONFIG-1
-- 为 PriorityCode 表增加 客户类型/订单类型 两个可空编码列（字典 Value）。
-- 幂等：用 information_schema 守卫，列已存在则跳过；不更新现有数据、不写默认值、不做破坏性操作。

SET @ddl_customer := (SELECT IF(
    EXISTS(SELECT 1 FROM information_schema.COLUMNS
           WHERE TABLE_SCHEMA = DATABASE()
             AND TABLE_NAME = 'PriorityCode'
             AND COLUMN_NAME = 'CustomerTypeCode'),
    'SELECT 1',
    'ALTER TABLE `PriorityCode` ADD COLUMN `CustomerTypeCode` varchar(50) NULL COMMENT ''客户类型编码（字典 s0_order_priority_customer_type 的 Value）'''));
PREPARE stmt_customer FROM @ddl_customer;
EXECUTE stmt_customer;
DEALLOCATE PREPARE stmt_customer;

SET @ddl_order := (SELECT IF(
    EXISTS(SELECT 1 FROM information_schema.COLUMNS
           WHERE TABLE_SCHEMA = DATABASE()
             AND TABLE_NAME = 'PriorityCode'
             AND COLUMN_NAME = 'OrderTypeCode'),
    'SELECT 1',
    'ALTER TABLE `PriorityCode` ADD COLUMN `OrderTypeCode` varchar(50) NULL COMMENT ''订单类型编码（字典 s0_order_type 的 Value）'''));
PREPARE stmt_order FROM @ddl_order;
EXECUTE stmt_order;
DEALLOCATE PREPARE stmt_order;
