This commit is contained in:
vipg
2025-12-19 12:37:10 +08:00
parent 094823d6a2
commit 5a5326fd36
2 changed files with 1 additions and 59 deletions

View File

@@ -26,7 +26,7 @@ BEGIN
CREATE TABLE trading_records (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY, -- id
event_type VARCHAR(40) NOT NULL, -- 事件名称
payload JSONB NOT NULL, -- 数据
payload JSONB NOT NULL, -- 数据
deleted BOOLEAN NOT NULL DEFAULT FALSE, -- 删除状态
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, -- 记录创建时间
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -- 记录修改时间
@@ -44,20 +44,6 @@ BEGIN
END IF;
END $$;
-- 4 索引(幂等)
CREATE INDEX IF NOT EXISTS idx_trd_open_ym
ON trading_records (open_year, open_month);
CREATE INDEX IF NOT EXISTS idx_trd_close_ym
ON trading_records (close_year, close_month)
WHERE close_year IS NOT NULL;
CREATE INDEX IF NOT EXISTS idx_trd_symbol_contract
ON trading_records (symbol, contract);
CREATE INDEX IF NOT EXISTS idx_trd_deleted_updated
ON trading_records (deleted, updated_at DESC);
DO $$
BEGIN
RAISE NOTICE '全部索引已确保存在';