migrations fix

This commit is contained in:
onysd 2026-07-21 00:18:12 +03:00
parent 865b5ff4f4
commit e84111732e
60 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,25 @@
-- TON-denominated channel marketplace proceeds remain a telesrv-local ledger.
-- No wallet, chain node, smart contract, Fragment or external RPC is involved.
CREATE TABLE public.channel_ton_balances (
channel_id bigint PRIMARY KEY,
balance_nanoton bigint DEFAULT 0 NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT channel_ton_balances_shape_check CHECK (channel_id>0 AND balance_nanoton>=0)
);
CREATE TABLE public.channel_ton_transactions (
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
channel_id bigint NOT NULL,
actor_user_id bigint NOT NULL,
amount_nanoton bigint NOT NULL,
reason text NOT NULL,
peer_type text DEFAULT '' NOT NULL,
peer_id bigint DEFAULT 0 NOT NULL,
gift_id bigint,
date integer NOT NULL,
CONSTRAINT channel_ton_transactions_shape_check CHECK (
channel_id>0 AND actor_user_id>0 AND amount_nanoton<>0 AND date>0 AND
((peer_type='' AND peer_id=0) OR (peer_type IN ('user','channel') AND peer_id>0)))
);
CREATE INDEX channel_ton_transactions_channel_idx
ON public.channel_ton_transactions(channel_id,id DESC);