Files
wish-pool/scripts/fix-migration-log-constraint.sql
2025-07-19 02:12:37 +08:00

26 lines
958 B
PL/PgSQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 修復 migration_log 表的約束問題
-- 允許 'storage_cleanup' 和 'data_cleanup' 類型
BEGIN;
-- 移除舊的約束
ALTER TABLE migration_log DROP CONSTRAINT IF EXISTS migration_log_migration_type_check;
-- 添加新的約束,包含所有需要的類型
ALTER TABLE migration_log ADD CONSTRAINT migration_log_migration_type_check
CHECK (migration_type IN ('wishes', 'likes', 'settings', 'storage_cleanup', 'data_cleanup', 'image_cleanup'));
-- 顯示結果
DO $$
BEGIN
RAISE NOTICE '✅ migration_log 表約束已更新';
RAISE NOTICE '📋 允許的 migration_type 值:';
RAISE NOTICE ' - wishes困擾案例遷移';
RAISE NOTICE ' - likes點讚記錄遷移';
RAISE NOTICE ' - settings用戶設定遷移';
RAISE NOTICE ' - storage_cleanup存儲清理';
RAISE NOTICE ' - data_cleanup數據清空';
RAISE NOTICE ' - image_cleanup圖片清理';
END $$;
COMMIT;