mirror of
https://github.com/wahyd4/home-docker.git
synced 2026-08-08 20:15:03 +10:00
demo-service: fix DB migration — add visibility column to existing tables
ALTER TABLE ADD COLUMN fails silently if column already exists (rather than crashing on startup).
This commit is contained in:
@@ -34,7 +34,12 @@ def _init_schema(conn: sqlite3.Connection):
|
||||
updated_at TEXT NOT NULL
|
||||
)
|
||||
""")
|
||||
# Migration: populate visibility from old enabled/published columns
|
||||
# Migration: add visibility column to existing tables (from v1 schema)
|
||||
try:
|
||||
conn.execute("ALTER TABLE sites ADD COLUMN visibility TEXT NOT NULL DEFAULT 'internal'")
|
||||
except sqlite3.OperationalError:
|
||||
pass # column already exists
|
||||
# Migrate old enabled/published data to visibility
|
||||
conn.execute("""
|
||||
UPDATE sites SET visibility = 'disabled' WHERE enabled = 0 AND visibility = 'internal'
|
||||
""")
|
||||
|
||||
Reference in New Issue
Block a user