Introduce background scheduling and migrations for analytics ingest, expand parser management and map toolbar UX, and ignore local data/session files from version control. Co-authored-by: Cursor <cursoragent@cursor.com>
29 lines
876 B
Python
29 lines
876 B
Python
from sqlalchemy import inspect, text
|
|
from sqlalchemy.engine import Engine
|
|
|
|
|
|
def migrate_schema(engine: Engine) -> None:
|
|
"""Apply lightweight schema updates for existing deployments."""
|
|
inspector = inspect(engine)
|
|
if "parse_jobs" not in inspector.get_table_names():
|
|
return
|
|
|
|
columns = {col["name"] for col in inspector.get_columns("parse_jobs")}
|
|
statements: list[str] = []
|
|
|
|
if "interval_seconds" not in columns:
|
|
statements.append(
|
|
"ALTER TABLE parse_jobs ADD COLUMN interval_seconds INTEGER NOT NULL DEFAULT 3600"
|
|
)
|
|
if "is_active" not in columns:
|
|
statements.append(
|
|
"ALTER TABLE parse_jobs ADD COLUMN is_active BOOLEAN NOT NULL DEFAULT TRUE"
|
|
)
|
|
|
|
if not statements:
|
|
return
|
|
|
|
with engine.begin() as conn:
|
|
for stmt in statements:
|
|
conn.execute(text(stmt))
|