feat(server/migrate): 000024 邀请奖励表 + subscriptions.source 扩 invite/task
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
-- 还原 subscriptions.source CHECK
|
||||
CREATE TABLE subscriptions_old (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
plan_id INTEGER NOT NULL,
|
||||
expires_at DATETIME NOT NULL,
|
||||
source TEXT NOT NULL CHECK (source IN ('trial','code','pay')),
|
||||
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id),
|
||||
FOREIGN KEY (plan_id) REFERENCES plans(id)
|
||||
);
|
||||
INSERT INTO subscriptions_old SELECT id,user_id,plan_id,expires_at,source,created_at
|
||||
FROM subscriptions WHERE source IN ('trial','code','pay');
|
||||
DROP TABLE subscriptions;
|
||||
ALTER TABLE subscriptions_old RENAME TO subscriptions;
|
||||
|
||||
DROP TABLE reward_claims;
|
||||
DROP TABLE referrals;
|
||||
DROP INDEX ux_users_invite_code;
|
||||
ALTER TABLE users DROP COLUMN first_paid_at;
|
||||
ALTER TABLE users DROP COLUMN invite_code;
|
||||
Reference in New Issue
Block a user