feat(server): 迁移 000021 pay_purchases 台账 + subscriptions.source 扩 pay
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
DROP TABLE IF EXISTS pay_purchases;
|
||||
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')),
|
||||
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 (id, user_id, plan_id, expires_at, source, created_at)
|
||||
SELECT id, user_id, plan_id, expires_at, source, created_at FROM subscriptions;
|
||||
DROP TABLE subscriptions;
|
||||
ALTER TABLE subscriptions_old RENAME TO subscriptions;
|
||||
CREATE INDEX idx_subs_user_exp ON subscriptions (user_id, expires_at);
|
||||
Reference in New Issue
Block a user