fix(backend): alembic drift PR-B — F3 14x index=True + F7 33x server_default (Option A) + env.py compare_* flags - #66
Conversation
…default (Option A) + env.py compare_* flags Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015G6Qu6rwJZYWjMdxU5bMVt
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #66 +/- ##
==========================================
+ Coverage 52.99% 53.02% +0.03%
==========================================
Files 110 110
Lines 6337 6337
Branches 1058 1058
==========================================
+ Hits 3358 3360 +2
+ Misses 2872 2871 -1
+ Partials 107 106 -1
... and 3 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Closes the MEDIUM canonicalization findings from the Alembic drift recon at
research/db_audit/ALEMBIC_DRIFT_RECON.mdv0.1. Second of three PRs in the AB-037 A/B/C sequence — PR-A (#65) shipped the runtime-bug fixes; this PR aligns model↔migration representation; PR-C will land the CI gate. Filed as AB-037B in the backlog.What this PR does
Aligns the SQLAlchemy model metadata with what the migrations actually build against Postgres, so
alembic revision --autogenerateproduces a clean empty diff going forward — instead of emitting spuriousop.drop_index()for 14 valid indexes + missing 33 server_default drift signals + missing type change signals.F3 — 14x
index=Trueaddedactionstype,target_id,created_atanomaliesservice_id,severity,is_activerecommendationsteam_id,workload_typerefresh_tokensexpires_atservicesteam_id,template_id,statususersrole,is_activeSQLAlchemy's default naming convention produces
ix_<table>_<col>— matches the migration index names exactly for all 14. Column types preserved.F7 — 33x
server_default=mirrored (Option A)All 33
server_default=declarations from the migrations are now mirrored in the models (matching values verbatim). Chose Option A over Option B because zero non-Python writers found in the codebase (grep-verified across airflow-worker, flink-jobs, normalizer, webhook-gateway, job-dispatcher) and zero migration seed-data, so explicit `server_default=` is defense-in-depth for any future writer AND enables `compare_server_default=True` to give accurate autogen signal.Both `default=` (Python-side) and `server_default=` (DB-side) are preserved — Python code paths continue to work identically.
env.py — compare flags enabled
Both `context.configure(...)` calls now pass `compare_server_default=True` + `compare_type=True`. Without these, autogen silently misses the drift classes that led to the 2026-09-01 recon (F5 ENUM, F6 token_hash length, F7 server_defaults).
Verification
Author-side:
Final `alembic revision --autogenerate should emit empty` verification requires a fresh dev Postgres — deferred to AB-037C's `alembic check` CI gate.
Scope
7 files, ~60 lines of substantive change (plus formatting):
`src/backend/app/db/models/team.py` — no changes (no F3/F7 columns).
Runtime impact
None. Metadata-only changes at the SQLAlchemy binding layer. No DDL, no data migration, no runtime behavior change.
References
🤖 Generated with Claude Code
https://claude.ai/code/session_015G6Qu6rwJZYWjMdxU5bMVt