新功能(#73): 新增促销系统数据库迁移

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
2026-05-26 22:04:44 -07:00
parent 5ebfe0a981
commit 9b88a1c7ca
2 changed files with 119 additions and 0 deletions
@@ -0,0 +1,41 @@
-- Purpose: Rollback promo system tables and order promo snapshot columns
SET @column_exists = (
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'order'
AND COLUMN_NAME = 'promo_discount'
);
SET @sql = IF(
@column_exists = 1,
'ALTER TABLE `order` DROP COLUMN `promo_discount`',
'SELECT ''Column promo_discount does not exist in order table'''
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @column_exists = (
SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'order'
AND COLUMN_NAME = 'promo_rule_id'
);
SET @sql = IF(
@column_exists = 1,
'ALTER TABLE `order` DROP COLUMN `promo_rule_id`',
'SELECT ''Column promo_rule_id does not exist in order table'''
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE IF EXISTS `promo_usage`;
DROP TABLE IF EXISTS `subscribe_promo`;
DROP TABLE IF EXISTS `promo_rule`;