27dc59ed63
- seed(sqlite/mysql 000007)+ 001_init:pro max_devices 5→3(全新库直接对) - 新增迁移 000019(sqlite/mysql,up/down):UPDATE plans SET max_devices=3 WHERE code='pro' —— 已迁移的线上库靠它更新;down 回退 5 - 000002/001 注释同步(free 1 / pro 3 / team 10) - 测试:sqlite_migrate 期望版本 18→19;devices 集成测试 pro 断言 5→3 - free(1)/team(10)不变 注:设备上限当前仍未强制执行(登录注册 MaxDevices=0),仅数据/展示口径; 真正启用+超限 UX 见 todo #16。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
21 lines
1018 B
SQL
21 lines
1018 B
SQL
-- 套餐与订阅(数字口径 = design/CLAUDE.md §7)
|
||
CREATE TABLE plans (
|
||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||
code ENUM('free','pro','team') NOT NULL UNIQUE,
|
||
max_devices INT NOT NULL, -- free 1 / pro 3 / team 10
|
||
daily_minutes INT NULL, -- free 10;NULL = 不限
|
||
ad_gate BOOLEAN NOT NULL DEFAULT FALSE -- free 每日看广告解锁
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||
|
||
CREATE TABLE subscriptions (
|
||
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
|
||
user_id BIGINT UNSIGNED NOT NULL,
|
||
plan_id BIGINT UNSIGNED NOT NULL,
|
||
expires_at DATETIME(6) NOT NULL,
|
||
source ENUM('trial','code') NOT NULL, -- 注册自动 7 天试用 source='trial'
|
||
created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
||
FOREIGN KEY (user_id) REFERENCES users(id),
|
||
FOREIGN KEY (plan_id) REFERENCES plans(id),
|
||
INDEX idx_user_exp (user_id, expires_at)
|
||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|