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>
48 lines
1.4 KiB
PL/PgSQL
48 lines
1.4 KiB
PL/PgSQL
-- This file is autogenerated from regen-schema.ts
|
|
create table if not exists
|
|
contract_liquidity (
|
|
contract_id text not null,
|
|
data jsonb not null,
|
|
liquidity_id text not null,
|
|
created_time timestamp with time zone default now(),
|
|
user_id text not null,
|
|
primary key (contract_id, liquidity_id)
|
|
);
|
|
|
|
-- Triggers
|
|
create trigger contract_liquidity_populate before insert
|
|
or
|
|
update on public.contract_liquidity for each row
|
|
execute function contract_liquidity_populate_cols ();
|
|
|
|
-- Functions
|
|
create
|
|
or replace function public.contract_liquidity_populate_cols () returns trigger language plpgsql as $function$
|
|
begin
|
|
if new.data is not null then
|
|
new.user_id := (new.data) ->> 'userId';
|
|
new.created_time := millis_to_ts(((new.data) ->> 'createdTime')::bigint);
|
|
end if;
|
|
return new;
|
|
end
|
|
$function$;
|
|
|
|
-- Row Level Security
|
|
alter table contract_liquidity enable row level security;
|
|
|
|
-- Policies
|
|
drop policy if exists "public read" on contract_liquidity;
|
|
|
|
create policy "public read" on contract_liquidity for
|
|
select
|
|
using (true);
|
|
|
|
-- Indexes
|
|
drop index if exists contract_liquidity_pkey;
|
|
|
|
create unique index contract_liquidity_pkey on public.contract_liquidity using btree (contract_id, liquidity_id);
|
|
|
|
drop index if exists contract_liquidity_user_id;
|
|
|
|
create index contract_liquidity_user_id on public.contract_liquidity using btree (user_id, created_time desc);
|