spark-server/migrations/0034_sign_energy.sql
DESKTOP-L8OUL9F\gfl0034 753c276496 feat: PopAdmin 拉取管理、签到能量 API 与图片 150KiB 硬上限
管理端按用户查询开启通讯录/相册/媒体拉取;服务端写入路径自动压图;新增 /v1/sign 与 /v1/energy。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-02 12:44:06 +08:00

31 lines
1.6 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 签到日历 + 能量钱包 / 流水(对齐客户端签到页与能量明细)。
CREATE TABLE IF NOT EXISTS t_user_wallets (
user_id BIGINT PRIMARY KEY COMMENT '用户 Snowflake uid',
energy BIGINT NOT NULL DEFAULT 0 COMMENT '能量余额',
updated_at DATETIME(3) NOT NULL COMMENT '更新时间'
) COMMENT='用户能量钱包';
CREATE TABLE IF NOT EXISTS t_energy_logs (
id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '流水自增 id',
user_id BIGINT NOT NULL COMMENT '用户 uid',
delta BIGINT NOT NULL COMMENT '变动值(可负)',
balance_after BIGINT NOT NULL DEFAULT 0 COMMENT '变动后余额',
reason VARCHAR(64) NOT NULL DEFAULT '' COMMENT '来源:sign/makeup/adjust',
day_key INT NOT NULL DEFAULT 0 COMMENT '关联签到日 YYYYMMDD,无则 0',
source VARCHAR(128) NOT NULL DEFAULT '' COMMENT '客户端展示文案',
created_at DATETIME(3) NOT NULL COMMENT '创建时间',
KEY idx_energy_logs_user_id (user_id, id)
) COMMENT='能量流水';
CREATE TABLE IF NOT EXISTS t_sign_records (
id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '签到记录自增 id',
user_id BIGINT NOT NULL COMMENT '用户 uid',
day_key INT NOT NULL COMMENT '签到日 YYYYMMDD',
kind TINYINT NOT NULL DEFAULT 1 COMMENT '1=当日签到 2=补签',
reward INT NOT NULL DEFAULT 0 COMMENT '当日发放能量',
created_at DATETIME(3) NOT NULL COMMENT '创建时间',
UNIQUE KEY uk_sign_user_day (user_id, day_key),
KEY idx_sign_user_day (user_id, day_key)
) COMMENT='用户签到/补签记录';