25 lines
621 B
Python
25 lines
621 B
Python
"""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()
|