31ece2e99a
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
17 lines
588 B
SQL
17 lines
588 B
SQL
create table if not exists candles (
|
|
id bigserial not null,
|
|
instrument_id bigint not null references instruments(id),
|
|
timeframe text not null,
|
|
ts_open timestamptz not null,
|
|
ts_close timestamptz not null,
|
|
open numeric(20,10) not null,
|
|
high numeric(20,10) not null,
|
|
low numeric(20,10) not null,
|
|
close numeric(20,10) not null,
|
|
volume numeric(28,10),
|
|
source text not null default 'api',
|
|
created_at timestamptz not null default now(),
|
|
primary key (id, ts_open),
|
|
unique (instrument_id, timeframe, ts_open)
|
|
) partition by range (ts_open);
|