predikt/oracle/backend/supabase/sweepstakes.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

33 lines
1.4 KiB
SQL

-- This file is autogenerated from regen-schema.ts
create table if not exists
sweepstakes (
sweepstakes_num integer primary key not null,
name text not null,
prizes jsonb not null, -- [{rank: 1, amountUsdc: 1000, label: "1st"}, {rankStart: 4, rankEnd: 10, amountUsdc: 50, label: "4th-10th"}]
close_time timestamp with time zone not null,
winning_ticket_ids text[], -- Array of winner ticket IDs in rank order
-- Provably fair: nonce stores the Bitcoin block hash used to determine winners.
-- NULL until winners are selected. The block used is the first one mined after close_time.
-- Users can verify by looking up the first block after close_time on any block explorer.
nonce text,
created_time timestamp with time zone default now() not null
);
-- Row Level Security
-- IMPORTANT: No public read policy! The nonce column is sensitive and must
-- only be exposed through the API after winner selection.
-- All access goes through the backend API which uses service role.
alter table sweepstakes enable row level security;
-- Drop any existing public read policy
drop policy if exists "public read" on sweepstakes;
-- Indexes
drop index if exists sweepstakes_pkey;
create unique index sweepstakes_pkey on public.sweepstakes using btree (sweepstakes_num);
drop index if exists sweepstakes_close_time;
create index sweepstakes_close_time on public.sweepstakes using btree (close_time);