Files
yhy-mager/backend/migrations/000015_payment_config_schema_repair.down.sql
xiewenjun dc2efcde08
Some checks failed
Check / delivery-static (push) Has been cancelled
Check / api (push) Has been cancelled
Check / web (push) Has been cancelled
feat: add online payment management and checkout
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
2026-10-15 09:26:40 +08:00

52 lines
1.8 KiB
SQL

-- Preserve the repaired schema-14 tables for current installations and restore
-- the retained early schema-14 table only when it can be renamed without loss.
SET @schema = DATABASE();
SET @sql = (
SELECT IF(
EXISTS (SELECT 1 FROM information_schema.table_constraints WHERE constraint_schema=@schema AND table_name='payment_orders' AND constraint_name='fk_payment_order_config_version'),
'ALTER TABLE payment_orders DROP FOREIGN KEY fk_payment_order_config_version',
'SELECT 1'
)
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @sql = (
SELECT IF(
EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema=@schema AND table_name='payment_orders' AND column_name='provider_config_version'),
'ALTER TABLE payment_orders DROP COLUMN provider_config_version',
'SELECT 1'
)
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @sql = (
SELECT IF(
EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema=@schema AND table_name='payment_channel_configs_legacy_v14')
AND EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema=@schema AND table_name='payment_channel_configs'),
'DROP TABLE payment_channel_configs',
'SELECT 1'
)
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET @sql = (
SELECT IF(
EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema=@schema AND table_name='payment_channel_configs_legacy_v14')
AND NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema=@schema AND table_name='payment_channel_configs'),
'RENAME TABLE payment_channel_configs_legacy_v14 TO payment_channel_configs',
'SELECT 1'
)
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
-- Never drop immutable configuration history during this repair rollback.