feat: 归档旧迁移文件,创建初始化数据迁移和重置脚本

This commit is contained in:
2026-04-14 11:24:35 +08:00
parent c35542f911
commit 5e9e41db21
231 changed files with 106 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
-- 添加订单过期时间字段和复合索引
DO $$
BEGIN
-- 添加 expires_at 字段订单过期时间NULL 表示不过期)
IF NOT EXISTS (
SELECT 1 FROM information_schema.columns
WHERE table_name='tb_order'
AND column_name='expires_at'
) THEN
ALTER TABLE tb_order ADD COLUMN expires_at TIMESTAMPTZ;
COMMENT ON COLUMN tb_order.expires_at IS '订单过期时间NULL表示不过期待支付订单默认30分钟后过期';
END IF;
-- 创建复合索引:用于定时任务扫描超时待支付订单
IF NOT EXISTS (
SELECT 1 FROM pg_indexes
WHERE tablename='tb_order'
AND indexname='idx_order_expires'
) THEN
CREATE INDEX idx_order_expires ON tb_order (expires_at, payment_status)
WHERE expires_at IS NOT NULL AND deleted_at IS NULL;
END IF;
END
$$;