predikt/oracle/backend/supabase/contract_movement_notifications.sql
caelum0x 2b68bde5d5 Predikt: full Polymarket-style prediction market — web + mobile + on-chain + bots
Working tree is now the canonical repo. Off-chain play-money + trustless on-chain
(FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution,
mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-06 23:29:50 +03:00

27 lines
1.2 KiB
SQL

create table if not exists
contract_movement_notifications (
id bigint primary key generated always as identity,
contract_id text not null,
answer_id text,
created_time timestamp with time zone default now() not null,
user_id text not null,
prev_val numeric not null,
new_val numeric not null,
prev_val_start_time timestamp with time zone default now() not null,
new_val_start_time timestamp with time zone default now() not null,
destination text not null, -- mobile, browser, email
notification_id text,
constraint fk_contract_id foreign key (contract_id) references contracts (id),
constraint fk_user_id foreign key (user_id) references users (id)
);
-- Row Level Security
alter table contract_movement_notifications enable row level security;
drop index if exists contract_notifications_contract_user_created_time_idx;
create index contract_notifications_contract_user_created_time_idx on contract_movement_notifications using btree (contract_id, user_id, created_time desc);
-- Add index to support the moving markets query
create index contract_notifications_created_time_contract_idx on contract_movement_notifications using btree (created_time desc, contract_id);