Files
ai-exchange/migrations/005_create_market_sessions.sql
2026-04-24 13:39:01 +08:00

24 lines
880 B
SQL

create table if not exists market_sessions (
id bigserial primary key,
instrument_id bigint not null references instruments(id),
session_date date not null,
timezone text not null,
session_code text not null,
start_ts timestamptz not null,
end_ts timestamptz not null,
high numeric(20,10),
low numeric(20,10),
midpoint numeric(20,10),
status text not null default 'closed',
meta jsonb not null default '{}'::jsonb,
created_at timestamptz not null default now(),
updated_at timestamptz not null default now(),
unique (instrument_id, session_date, session_code, timezone)
);
create index if not exists idx_market_sessions_instr_date
on market_sessions (instrument_id, session_date desc);
create index if not exists idx_market_sessions_instr_code_date
on market_sessions (instrument_id, session_code, session_date desc);