Repository navigation
fix: recreate the credential table skipped on databases created on v0.9.7 - #947
Merged
cristian-tamblay merged 1 commit intoOct 27, 2026
Merged
Conversation
…ation Databases created on v0.9.7.post1 or v0.9.7.post2 applied a7d2c9e4f1b0 while its parent was f1a2b3c4d5e6. The merge 3f7083c later rewrote that parent to d4e8a2c6f0b1 (credential table), so Alembic treats it as applied on those databases and never creates the table. - New head revision 72db19a8ec8d creates the table when it is missing. - scripts/ci_alembic_history.py adds two checks: published migrations must keep their id and parent, and a database created on each of the last releases must upgrade to the same schema as a fresh one. - The DB Migrations workflow runs both.
cristian-tamblay
deleted the
fix/credential-table-missing-after-upgrade
branch
October 27, 2026 15:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Databases created on v0.9.7.post1 or v0.9.7.post2 (or on develop between 2026-07-02 and 2026-08-14) end up without the
credentialtable after updating to 0.10.0 or develop. The app boots normally because the table is only touched lazily, and every/api/v1/credential/request then fails withno such table: credential. This surfaced on a server install that had been running for months and was updated to today's develop.Cause.
a7d2c9e4f1b0(model_name on parameter_history) reached develop on 2026-07-02 with parentf1a2b3c4d5e6. The merge3f7083c5d(2026-07-23, develop intofeat/base-credential) rewrote its parent tod4e8a2c6f0b1, the revision that createscredential, and that reached develop with #710 on 2026-08-14. Alembic stores only the current revision and treats every ancestor of it as applied, so on a database that already hada7d2c9e4f1b0,d4e8a2c6f0b1is never run. v0.9.7.post1 (2026-08-07) and v0.9.7.post2 (2026-08-12) shippeda7d2c9e4f1b0without the credential migration; v0.10.0 shipped the rewritten chain.Scope, verified by simulation. A database built with the migrations of each tag from v0.9.0 to v0.10.0 and upgraded with develop's migrations was compared (tables, columns, unique constraints, indexes, foreign keys) with a database created from scratch. Only the two v0.9.7 tags differ, and only by the missing
credentialtable. The other revision rewritten in that window (e0f00f71ba44, afterb2c3d4e5f6a7was renamed tod1c2b3a4f5e6in31dee775e) is harmless: its content was already applied under the old id, so skipping it is correct.The existing
DB Migrationsworkflow could not catch this: it only runs base → head → base → head on an empty database.Type of Change
Check all that apply like this [x]:
Changes (by file)
DashAI/alembic/versions/72db19a8ec8d_ensure_credential_table_exists.py: new head revision. Createscredentialwith the same DDL asd4e8a2c6f0b1when the table is missing, does nothing otherwise. Downgrade is a no-op becaused4e8a2c6f0b1owns the table.scripts/ci_alembic_history.py: two checks that protect databases out there.check-parents REF...: fails if a migration present in a git ref is missing from the working tree or has a differentdown_revision. This is the edit that caused the bug.upgrade-from REF...: builds a database with each ref's migrations (viagit archive), upgrades it with the working-tree migrations and diffs the schema against a fresh database. It drives the migrations through-x urlso theDATABASE_URLthe workflow sets is never touched, and lists the revisions Alembic counts as applied without running them..github/workflows/db-migrations.yaml:fetch-depth: 0(tags and base branch are needed),check-parentsagainst the latest tag plus the PR base branch, andupgrade-fromagainst the last 8 tags after the existing steps.tests/back/migrations/test_ensure_credential_table_exists.py: the revision recreates the table when it is missing, and leaves an existing table and its rows alone on upgrade and downgrade.Testing
Run locally on this branch:
pytest tests/back/migrations: 17 passed.check-parents v0.10.0 origin/develop: passes. Againstv0.9.7.post2it reports the three historical rewrites, which is why the workflow compares against the latest tag only;upgrade-fromis what covers the older ones.upgrade-fromon the last 8 tags: all OK, withDATABASE_URLpointing at a decoy file that was never created. With the new migration removed,v0.9.7.post2fails withmissing table credential.upgrade head,downgrade base,upgrade head,ci_alembic_check): pass.Notes
down_revision(or the id) of a migration that already reached develop or a release. Two heads are joined with a merge revision (alembic merge). CI now enforces this against the base branch of every PR.