feat: sync official star gift lifecycle tooling
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.
This commit is contained in:
parent
f2c2fd0236
commit
14bf7d1e20
92 changed files with 14768 additions and 727 deletions
40
deploy/migrations/0097_star_gift_peer_stars_ledger.up.sql
Normal file
40
deploy/migrations/0097_star_gift_peer_stars_ledger.up.sql
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
-- Owner-scoped Stars revenue for channel Star Gifts. These are internal
|
||||
-- telesrv ledgers only; no blockchain, wallet, TON node or Fragment endpoint is
|
||||
-- contacted. Conversion is recorded as one aggregate terminal transition.
|
||||
|
||||
CREATE TABLE public.channel_stars_balances (
|
||||
channel_id bigint PRIMARY KEY,
|
||||
balance bigint DEFAULT 0 NOT NULL,
|
||||
updated_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||
CONSTRAINT channel_stars_balances_shape_check CHECK (channel_id>0 AND balance>=0)
|
||||
);
|
||||
|
||||
CREATE TABLE public.channel_stars_transactions (
|
||||
id bigint GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
channel_id bigint NOT NULL,
|
||||
actor_user_id bigint NOT NULL,
|
||||
amount 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_stars_transactions_shape_check CHECK (
|
||||
channel_id>0 AND actor_user_id>0 AND amount<>0 AND date>0 AND
|
||||
((peer_type='' AND peer_id=0) OR (peer_type IN ('user','channel') AND peer_id>0)))
|
||||
);
|
||||
CREATE INDEX channel_stars_transactions_channel_idx
|
||||
ON public.channel_stars_transactions(channel_id,id DESC);
|
||||
|
||||
CREATE TABLE public.star_gift_conversions (
|
||||
saved_gift_id bigint PRIMARY KEY REFERENCES public.peer_star_gifts(id) ON DELETE RESTRICT,
|
||||
actor_user_id bigint NOT NULL,
|
||||
owner_peer_type text NOT NULL,
|
||||
owner_peer_id bigint NOT NULL,
|
||||
amount bigint NOT NULL,
|
||||
balance_after bigint NOT NULL,
|
||||
converted_at integer NOT NULL,
|
||||
CONSTRAINT star_gift_conversions_shape_check CHECK (
|
||||
actor_user_id>0 AND owner_peer_type IN ('user','channel') AND owner_peer_id>0 AND
|
||||
amount>=0 AND balance_after>=0 AND converted_at>0)
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue