Auto-commit local changes before build (2026-01-19 15:40:00)
This commit is contained in:
parent
8407bf45ab
commit
a7a61fdd64
@ -1 +1 @@
|
|||||||
v20260119-14-fix-routes-runchecks-syntax
|
v20260119-15-fix-migrations-autotask-phase2
|
||||||
|
|||||||
@ -43,6 +43,30 @@ def _column_exists_on_conn(conn, table_name: str, column_name: str) -> bool:
|
|||||||
return result.first() is not None
|
return result.first() is not None
|
||||||
|
|
||||||
|
|
||||||
|
def _get_table_columns(conn, table_name: str) -> set[str]:
|
||||||
|
"""Return a set of column names for the given table using the provided connection.
|
||||||
|
|
||||||
|
This helper is designed for use inside engine.begin() blocks so that any
|
||||||
|
errors are properly rolled back before the connection is returned to the pool.
|
||||||
|
|
||||||
|
If the table does not exist (or cannot be inspected), an empty set is returned.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
result = conn.execute(
|
||||||
|
text(
|
||||||
|
"""
|
||||||
|
SELECT column_name
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name = :table
|
||||||
|
"""
|
||||||
|
),
|
||||||
|
{"table": table_name},
|
||||||
|
)
|
||||||
|
return {row[0] for row in result.fetchall()}
|
||||||
|
except Exception:
|
||||||
|
return set()
|
||||||
|
|
||||||
|
|
||||||
def migrate_add_username_to_users() -> None:
|
def migrate_add_username_to_users() -> None:
|
||||||
"""Ensure users.username column exists and is NOT NULL and UNIQUE.
|
"""Ensure users.username column exists and is NOT NULL and UNIQUE.
|
||||||
|
|
||||||
@ -925,9 +949,10 @@ def migrate_job_runs_autotask_ticket_fields() -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with engine.connect() as conn:
|
with engine.begin() as conn:
|
||||||
cols = _get_table_columns(conn, table)
|
cols = _get_table_columns(conn, table)
|
||||||
if not cols:
|
if not cols:
|
||||||
|
print("[migrations] job_runs table not found; skipping migrate_job_runs_autotask_ticket_fields.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if "autotask_ticket_id" not in cols:
|
if "autotask_ticket_id" not in cols:
|
||||||
@ -957,12 +982,12 @@ def migrate_job_runs_autotask_ticket_fields() -> None:
|
|||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print(
|
print(
|
||||||
f"[migrations] Could not add FK job_runs.autotask_ticket_created_by_user_id -> users.id (continuing): {exc}"
|
f"[migrations] Could not add FK job_runs_autotask_ticket_created_by_user_id -> users.id (continuing): {exc}"
|
||||||
)
|
)
|
||||||
|
|
||||||
conn.execute(text('CREATE INDEX IF NOT EXISTS idx_job_runs_autotask_ticket_id ON "job_runs" (autotask_ticket_id)'))
|
conn.execute(text('CREATE INDEX IF NOT EXISTS idx_job_runs_autotask_ticket_id ON "job_runs" (autotask_ticket_id)'))
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
print(f"[migrations] job_runs table not found; skipping migrate_job_runs_autotask_ticket_fields: {exc}")
|
print(f"[migrations] migrate_job_runs_autotask_ticket_fields failed (continuing): {exc}")
|
||||||
return
|
return
|
||||||
|
|
||||||
print("[migrations] migrate_job_runs_autotask_ticket_fields completed.")
|
print("[migrations] migrate_job_runs_autotask_ticket_fields completed.")
|
||||||
@ -1269,9 +1294,10 @@ def migrate_tickets_resolved_origin() -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with engine.connect() as conn:
|
with engine.begin() as conn:
|
||||||
cols = _get_table_columns(conn, table)
|
cols = _get_table_columns(conn, table)
|
||||||
if not cols:
|
if not cols:
|
||||||
|
print("[migrations] tickets table not found; skipping migrate_tickets_resolved_origin.")
|
||||||
return
|
return
|
||||||
if "resolved_origin" not in cols:
|
if "resolved_origin" not in cols:
|
||||||
print("[migrations] Adding tickets.resolved_origin column...")
|
print("[migrations] Adding tickets.resolved_origin column...")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user