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

60 lines
1.7 KiB
PL/PgSQL

-- This file is autogenerated from regen-schema.ts
create table if not exists
group_invites (
created_time timestamp with time zone default now() not null,
duration interval default '7 days'::interval,
expire_time timestamp with time zone,
group_id text not null,
id text primary key default random_alphanumeric (12) not null,
is_forever boolean generated always as (
case
when duration is null then true
else false
end
) stored,
is_max_uses_reached boolean generated always as (
case
when max_uses is null then false
else uses >= max_uses
end
) stored,
max_uses numeric,
uses numeric default 0 not null
);
-- Foreign Keys
alter table group_invites
add constraint public_group_invites_group_id_fkey foreign key (group_id) references groups (id) on update cascade on delete cascade;
-- Triggers
create trigger populate_group_invites_expire_time before insert on public.group_invites for each row
execute function set_expire_time ();
-- Functions
create
or replace function public.set_expire_time () returns trigger language plpgsql as $function$
BEGIN
IF NEW.duration IS NULL THEN
NEW.expire_time = NULL;
ELSE
NEW.expire_time = NEW.created_time + NEW.duration;
END IF;
RETURN NEW;
END;
$function$;
-- Row Level Security
alter table group_invites enable row level security;
-- Policies
drop policy if exists "Enable read access for admin" on group_invites;
create policy "Enable read access for admin" on group_invites for
select
to service_role using (true);
-- Indexes
drop index if exists group_invites_pkey;
create unique index group_invites_pkey on public.group_invites using btree (id);