24 lines
1.4 KiB
SQL
24 lines
1.4 KiB
SQL
-- Star gift(payments.sendStarsForm + inputInvoiceStarGift):用户花 Stars 给另一用户送礼物
|
||
-- (贴纸式收藏品)。此前 getStarGifts/getSavedStarGifts 返回空桩、getPaymentForm/sendStarsForm
|
||
-- 未注册。目录是从已 seed 的 animated_emoji 合成的静态内存表(不入库);本表存「已收到的礼物
|
||
-- 实例」。配合 Stars 账本(迁移 0009):发礼 Debit、转换回 Stars 时 Credit。
|
||
-- msg_id 是礼物在 owner 私聊里的服务消息 id(messageActionStarGift),是 save/convert 的身份键
|
||
-- (对应 inputSavedStarGiftUser.msg_id)。
|
||
CREATE TABLE public.user_star_gifts (
|
||
id bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL,
|
||
owner_user_id bigint NOT NULL,
|
||
from_user_id bigint DEFAULT 0 NOT NULL,
|
||
gift_id bigint NOT NULL,
|
||
msg_id integer NOT NULL,
|
||
gift_date integer DEFAULT 0 NOT NULL,
|
||
name_hidden boolean DEFAULT false NOT NULL,
|
||
unsaved boolean DEFAULT false NOT NULL,
|
||
converted boolean DEFAULT false NOT NULL,
|
||
convert_stars bigint DEFAULT 0 NOT NULL,
|
||
message text DEFAULT '' NOT NULL,
|
||
CONSTRAINT user_star_gifts_pkey PRIMARY KEY (id),
|
||
CONSTRAINT user_star_gifts_owner_msg_uniq UNIQUE (owner_user_id, msg_id)
|
||
);
|
||
|
||
-- getSavedStarGifts keyset 分页按 (owner, gift_date DESC, id DESC)。
|
||
CREATE INDEX user_star_gifts_owner_idx ON public.user_star_gifts USING btree (owner_user_id, gift_date DESC, id DESC);
|