9b88a1c7ca
Co-authored-by: multica-agent <github@multica.ai>
42 lines
997 B
SQL
42 lines
997 B
SQL
-- 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`;
|