create table if not exists sweep_events ( id bigserial primary key, instrument_id bigint not null references instruments(id), timeframe text not null, side_swept text not null, pool_id bigint not null references liquidity_pools(id), sweep_high numeric(20,10) not null, sweep_low numeric(20,10) not null, sweep_ts timestamptz not null, close_back_inside boolean not null default false, validation_level text not null default 'weak', status text not null default 'active', meta jsonb not null default '{}'::jsonb, created_at timestamptz not null default now(), unique (instrument_id, timeframe, pool_id, sweep_ts) ); create index if not exists idx_sweep_events_instr_tf_ts_desc on sweep_events (instrument_id, timeframe, sweep_ts desc); create index if not exists idx_sweep_events_pool_ts_desc on sweep_events (pool_id, sweep_ts desc);