You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Models live in datagov-data-access; Alembic migrations live here. Nothing enforces that a model column added there gets a migration here, so a version bump can land a column the database does not have. Any query selecting the model then fails with column ... does not exist.
This has now happened twice with the same column
harvest_job.records_warned was added to the model in data-access 1.1.0.
Both landed. After #793 merged main, the branch had two Alembic heads and two migrations adding the same column. flask db upgrade runs on every deploy (app-start.sh:9) and fails on multiple heads, so the branch would have broken deploys. Fixed in 9a4f5c9 by dropping the duplicate and relinking to a single head.
So the failure mode is not only "migration missing" — it is also "two people write the same migration and collide."
Suggested guards
CI check for multiple heads. Cheap and catches the collision class directly:
flask db heads # fail the build if it reports more than one
CI check that models match migrations.alembic check (or autogenerate-and-diff) fails when a model column has no corresponding migration, catching the drift at the bump rather than in production.
Checklist item on data-access bump PRs: state explicitly whether the release added or changed columns, and link the migration if so.
The first two are the durable fixes; the multiple-heads check alone would have caught this instance in CI.
Reference
Column: harvest_job.records_warned, server_default="0", added in data-access 1.1.0
Migration on main: migrations/versions/b3f4a9c1d7e2_add_records_warned_to_harvest_job.py
Models live in
datagov-data-access; Alembic migrations live here. Nothing enforces that a model column added there gets a migration here, so a version bump can land a column the database does not have. Any query selecting the model then fails withcolumn ... does not exist.This has now happened twice with the same column
harvest_job.records_warnedwas added to the model in data-access 1.1.0.b3f4a9c1d7e2).f4a2b8c15d93).Both landed. After #793 merged main, the branch had two Alembic heads and two migrations adding the same column.
flask db upgraderuns on every deploy (app-start.sh:9) and fails on multiple heads, so the branch would have broken deploys. Fixed in 9a4f5c9 by dropping the duplicate and relinking to a single head.So the failure mode is not only "migration missing" — it is also "two people write the same migration and collide."
Suggested guards
alembic check(or autogenerate-and-diff) fails when a model column has no corresponding migration, catching the drift at the bump rather than in production.The first two are the durable fixes; the multiple-heads check alone would have caught this instance in CI.
Reference
harvest_job.records_warned,server_default="0", added in data-access 1.1.0migrations/versions/b3f4a9c1d7e2_add_records_warned_to_harvest_job.py