chore: stage changes before history rewrite

This commit is contained in:
2026-07-07 11:28:18 +08:00
parent a619b919be
commit 137304090a
13 changed files with 670 additions and 83 deletions

View File

@@ -0,0 +1,20 @@
"""Migrate: add permissions column to api_keys table."""
import sqlite3
from pathlib import Path
DB_PATH = Path(__file__).parent.parent / "postcard.db"
conn = sqlite3.connect(str(DB_PATH))
cur = conn.cursor()
cur.execute("PRAGMA table_info(api_keys)")
cols = [r[1] for r in cur.fetchall()]
if "permissions" not in cols:
cur.execute('ALTER TABLE api_keys ADD COLUMN permissions TEXT NOT NULL DEFAULT "[]"')
conn.commit()
print("OK: column 'permissions' added to api_keys")
else:
print("SKIP: column 'permissions' already exists")
conn.close()

View File

@@ -0,0 +1,24 @@
"""Migrate: create system_config table."""
import sqlite3
from pathlib import Path
DB_PATH = Path(__file__).parent.parent / "postcard.db"
conn = sqlite3.connect(str(DB_PATH))
cur = conn.cursor()
cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='system_config'")
if not cur.fetchone():
cur.execute(
"CREATE TABLE system_config ("
"key TEXT PRIMARY KEY, "
"value TEXT NOT NULL DEFAULT '', "
"updated_at TIMESTAMP"
")"
)
conn.commit()
print("OK: system_config table created")
else:
print("SKIP: system_config table exists")
conn.close()