Sync telesrv 4c0e2d9 (feat: complete official star gift lifecycle and admin tooling). Public adjustments: skipped private docs/deploy-nginx/README source changes, kept iamxvbaba/td public dependency, replaced local/private sample IP and orange seed label.
25 lines
1.1 KiB
SQL
25 lines
1.1 KiB
SQL
-- 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);
|