feat(work-order): 新增一次性补资料链接

This commit is contained in:
2026-11-01 10:46:31 +08:00
parent fba0a13d44
commit 15956e704f
26 changed files with 1768 additions and 4 deletions
@@ -0,0 +1,48 @@
-- 旧 103–112 → 当前 103–108 迁移历史校准。
--
-- 适用场景:数据库已经执行过旧迁移名
-- 103_product_catalog / 104_cost_center / 105_sales_daily_facts /
-- 106_order_refunds / 107_manual_fulfillment / 108_finance_cost_integrity /
-- 109_work_order_share_participation / 110_work_order_hall_and_shop_indexes /
-- 111_work_order_share_cancel_reason_comment / 112_consignment_contact_supporter
-- 但当前代码已经把 103–108 收敛成新的幂等迁移文件。
--
-- 新库不需要执行本脚本,直接按当前迁移文件跑即可。
-- 执行本脚本后,请运行 npm run db:migrate,让 node-pg-migrate 应用当前 103–108。
--
-- 注意:执行前请先做全量数据库备份。本脚本只清理 schema_migrations 元数据,
-- 不删业务表;当前 103–108 迁移文件本身保持幂等,重复执行不会重复建对象。
BEGIN;
-- 保留一份执行前的迁移记录,便于核对;已存在时不覆盖。
CREATE TABLE IF NOT EXISTS schema_migrations_backup_20261031_before_103
AS SELECT * FROM schema_migrations;
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM schema_migrations WHERE name = '103_product_catalog'
) THEN
RAISE NOTICE '未检测到旧 103_product_catalog,跳过迁移历史校准';
RETURN;
END IF;
DELETE FROM schema_migrations
WHERE name IN (
'103_product_catalog',
'104_cost_center',
'105_sales_daily_facts',
'106_order_refunds',
'107_manual_fulfillment',
'108_finance_cost_integrity',
'109_work_order_share_participation',
'110_work_order_hall_and_shop_indexes',
'111_work_order_share_cancel_reason_comment',
'112_consignment_contact_supporter'
);
RAISE NOTICE '已清理旧 103–112 迁移记录,请执行 npm run db:migrate 应用当前 103–108';
END $$;
COMMIT;