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>
60 lines
2.4 KiB
SQL
60 lines
2.4 KiB
SQL
-- This file is autogenerated from regen-schema.ts
|
|
create table if not exists
|
|
personalized_mana_offers (
|
|
activated_at timestamp with time zone,
|
|
created_at timestamp with time zone default now() not null,
|
|
dismissed_at timestamp with time zone,
|
|
expires_at timestamp with time zone,
|
|
id text primary key default random_alphanumeric (12) not null,
|
|
mana_amount integer default 5000 not null,
|
|
payment_pending_at timestamp with time zone,
|
|
payment_pending_session_id text,
|
|
price_usd_crypto integer default 35 not null,
|
|
price_usd_stripe integer default 40 not null,
|
|
redeemed_at timestamp with time zone,
|
|
redemption_method text,
|
|
redemption_session_id text,
|
|
shop_order_id uuid not null,
|
|
source text default 'merch_shipped'::text not null,
|
|
status text default 'pending'::text not null,
|
|
stripe_promotion_code_id text,
|
|
user_id text not null,
|
|
voided_reason text,
|
|
constraint personalized_mana_offers_status_check check (
|
|
status = any (array['pending'::text, 'active'::text, 'redeemed'::text, 'expired'::text, 'voided'::text])
|
|
),
|
|
constraint personalized_mana_offers_redemption_method_check check (
|
|
redemption_method is null
|
|
or redemption_method = any (array['stripe'::text, 'crypto'::text])
|
|
)
|
|
);
|
|
|
|
-- Foreign Keys
|
|
alter table personalized_mana_offers
|
|
add constraint personalized_mana_offers_user_id_fkey foreign key (user_id) references users (id);
|
|
|
|
alter table personalized_mana_offers
|
|
add constraint personalized_mana_offers_shop_order_id_fkey foreign key (shop_order_id) references shop_orders (id);
|
|
|
|
-- Row Level Security
|
|
alter table personalized_mana_offers enable row level security;
|
|
|
|
-- Indexes
|
|
drop index if exists personalized_mana_offers_pkey;
|
|
|
|
create unique index personalized_mana_offers_pkey on public.personalized_mana_offers using btree (id);
|
|
|
|
drop index if exists personalized_mana_offers_shop_order_id_key;
|
|
|
|
create unique index personalized_mana_offers_shop_order_id_key on public.personalized_mana_offers using btree (shop_order_id);
|
|
|
|
drop index if exists personalized_mana_offers_user_status_idx;
|
|
|
|
create index personalized_mana_offers_user_status_idx on public.personalized_mana_offers using btree (user_id, status);
|
|
|
|
drop index if exists personalized_mana_offers_active_expires_idx;
|
|
|
|
create index personalized_mana_offers_active_expires_idx on public.personalized_mana_offers using btree (expires_at)
|
|
where
|
|
(status = 'active'::text);
|