Spaces:
Runtime error
Runtime error
fix: auto-migrate sightings table to add is_help_event and help_type columns
Browse files- core/database.py +6 -0
core/database.py
CHANGED
|
@@ -63,6 +63,12 @@ class Database:
|
|
| 63 |
" created_at DATETIME DEFAULT CURRENT_TIMESTAMP"
|
| 64 |
");"
|
| 65 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
# βββ Photos ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 68 |
|
|
|
|
| 63 |
" created_at DATETIME DEFAULT CURRENT_TIMESTAMP"
|
| 64 |
");"
|
| 65 |
)
|
| 66 |
+
# Incremental migrations β safe to run on every startup
|
| 67 |
+
cols = {row[1] for row in conn.execute("PRAGMA table_info(sightings)").fetchall()}
|
| 68 |
+
if "is_help_event" not in cols:
|
| 69 |
+
conn.execute("ALTER TABLE sightings ADD COLUMN is_help_event INTEGER NOT NULL DEFAULT 0")
|
| 70 |
+
if "help_type" not in cols:
|
| 71 |
+
conn.execute("ALTER TABLE sightings ADD COLUMN help_type TEXT")
|
| 72 |
|
| 73 |
# βββ Photos ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 74 |
|