Auto-commit local changes before build (2026-03-20 12:04:24)
This commit is contained in:
parent
22a12348cb
commit
fb841fb4e6
@ -1366,6 +1366,38 @@ def migrate_cc_accounts_repo_unique_key() -> None:
|
|||||||
print(f"[migrations] Failed migrate_cc_accounts_repo_unique_key: {exc}")
|
print(f"[migrations] Failed migrate_cc_accounts_repo_unique_key: {exc}")
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_cc_remove_synthetic_missed_runs() -> None:
|
||||||
|
"""Remove synthetic missed runs that were incorrectly generated for Cloud Connect jobs.
|
||||||
|
|
||||||
|
Cloud Connect jobs do not have a fixed schedule — the daily report email can arrive at
|
||||||
|
different times of day. The schedule-inference + missed-run generator would create phantom
|
||||||
|
'missed' entries when the delivery time shifted (e.g. from 18:55 to 10:24). These are now
|
||||||
|
suppressed in code; this migration cleans up any that were already stored.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
engine = db.get_engine()
|
||||||
|
except Exception as exc:
|
||||||
|
print(f"[migrations] Could not get engine for cc missed-run cleanup: {exc}")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
with engine.begin() as conn:
|
||||||
|
result = conn.execute(text("""
|
||||||
|
DELETE FROM job_runs
|
||||||
|
WHERE missed = true
|
||||||
|
AND mail_message_id IS NULL
|
||||||
|
AND external_id IS NULL
|
||||||
|
AND job_id IN (
|
||||||
|
SELECT id FROM jobs
|
||||||
|
WHERE LOWER(backup_type) IN ('cloud connect backup', 'cloud connect agent')
|
||||||
|
)
|
||||||
|
"""))
|
||||||
|
deleted = result.rowcount
|
||||||
|
print(f"[migrations] migrate_cc_remove_synthetic_missed_runs completed ({deleted} rows removed).")
|
||||||
|
except Exception as exc:
|
||||||
|
print(f"[migrations] Failed migrate_cc_remove_synthetic_missed_runs: {exc}")
|
||||||
|
|
||||||
|
|
||||||
def run_migrations() -> None:
|
def run_migrations() -> None:
|
||||||
print("[migrations] Starting migrations...")
|
print("[migrations] Starting migrations...")
|
||||||
migrate_add_username_to_users()
|
migrate_add_username_to_users()
|
||||||
@ -1413,6 +1445,7 @@ def run_migrations() -> None:
|
|||||||
migrate_cove_accounts_table()
|
migrate_cove_accounts_table()
|
||||||
migrate_cloud_connect_accounts_table()
|
migrate_cloud_connect_accounts_table()
|
||||||
migrate_cc_accounts_repo_unique_key()
|
migrate_cc_accounts_repo_unique_key()
|
||||||
|
migrate_cc_remove_synthetic_missed_runs()
|
||||||
migrate_entra_sso_settings()
|
migrate_entra_sso_settings()
|
||||||
print("[migrations] All migrations completed.")
|
print("[migrations] All migrations completed.")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user