predikt/oracle/backend/supabase/migrations/2026060701_sweepstakes_tickets_voided.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

23 lines
1.1 KiB
SQL

-- Void columns on sweepstakes_tickets — companion to the prize-eligibility
-- decoupling and the admin-driven refund flow.
--
-- When an admin flips a user to prizeEligibility = 'ineligible' with
-- voidOutstandingTickets: true (e.g. an under-18 case where their parents
-- want the mana refunded, or a confirmed alt where we want the entry pool
-- cleaned up), the user's outstanding tickets in unresolved drawings are
-- stamped here and their mana is refunded via SWEEPSTAKES_TICKET_REFUND.
--
-- Voided rows survive for audit. They're excluded from the draw and the
-- claim by the `voided_at IS NULL` predicate at both call sites.
ALTER TABLE sweepstakes_tickets
ADD COLUMN IF NOT EXISTS voided_at timestamp with time zone,
ADD COLUMN IF NOT EXISTS voided_reason text;
-- Partial index over active (non-voided) tickets in a sweepstakes.
-- selectSweepstakesWinners and the buy-flow bonding-curve query both scan
-- by sweepstakes_num and care only about live rows.
CREATE INDEX IF NOT EXISTS idx_sweepstakes_tickets_active
ON sweepstakes_tickets (sweepstakes_num)
WHERE voided_at IS NULL;