返回 DeepSeek-Reasonix
migrate.sql
根目录 / workers / crash-report / migrate.sql
1 -- One-time upgrade of the live reasonix-crash DB to the account system.
2 -- Apply once: wrangler d1 execute reasonix-crash --remote --file=migrate.sql
3 -- The ALTERs are not idempotent; the CREATEs are. Fresh installs use schema.sql.
4 ALTER TABLE groups ADD COLUMN status TEXT NOT NULL DEFAULT 'open';
5 ALTER TABLE groups ADD COLUMN note TEXT NOT NULL DEFAULT '';
6
7 CREATE TABLE IF NOT EXISTS users (
8 id INTEGER PRIMARY KEY AUTOINCREMENT,
9 email TEXT NOT NULL UNIQUE,
10 password_hash TEXT NOT NULL,
11 role TEXT NOT NULL DEFAULT 'pending',
12 created_at TEXT NOT NULL,
13 approved_at TEXT,
14 approved_by INTEGER
15 );
16
17 CREATE TABLE IF NOT EXISTS sessions (
18 token TEXT PRIMARY KEY,
19 user_id INTEGER NOT NULL,
20 created_at TEXT NOT NULL,
21 expires_at TEXT NOT NULL
22 );
23
24 CREATE INDEX IF NOT EXISTS sessions_user ON sessions (user_id);
25
26 CREATE TABLE IF NOT EXISTS audit_log (
27 id INTEGER PRIMARY KEY AUTOINCREMENT,
28 at TEXT NOT NULL,
29 actor_id INTEGER,
30 actor_email TEXT NOT NULL,
31 action TEXT NOT NULL,
32 target TEXT NOT NULL DEFAULT '',
33 detail TEXT NOT NULL DEFAULT ''
34 );
35
35 lines SQL