add
This commit is contained in:
@@ -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 '全部索引已确保存在';
|
||||
|
||||
Reference in New Issue
Block a user