Test that Alembic migrations run and match the models #133
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "test-alembic-migrations"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The backend suite builds its schema with
Base.metadata.create_all(tests/conftest.py), so no test ever executed a migration: a revision that is broken, missing, or out of step with the models still showed a green run - andupgrade headruns at application startup, so that is exactly the kind of thing that only surfaces in production.What this adds
backend/tests/integration/test_migrations.pywith two integration tests:The tests run against a file-backed throwaway database. Pointing
WAGGLE_TEST_MIGRATION_URLat a Postgres database runs the same assertions there; a guard rail refuses any database whose name does not end in_migrationsor_test, because the fixture wipes it withDROP SCHEMA public CASCADE.CI runs the tests twice:
backend-test-postgresjob, against a dedicatedwaggle_migrationsdatabase.SQLite (batch-mode table rebuild) and Postgres (
ALTER TABLE) are different Alembic code paths; a revision can pass on one and fail on the other, and production runs Postgres - this is what validates the production configuration.Relation to #123
Split out of #123 so the migration safety net is not tied to the composite-FK work. #123 keeps its FK-specific migration tests (constraint survival, accept/reject behaviour, data backfill) and will be rebased on top once this merges.
Overbodig geworden: PR #123 is gemerged en bracht de volledige migratie-testharnas al naar main - dezelfde twee tests hier plus vier extra (composite FKs, partiële index, insert/reject, backfill), dezelfde CI-stap 'Alembic migrations against Postgres' en dezelfde CHANGELOG-regel. Het add/add-conflict op test_migrations.py is precies die overlap. Deze PR sluit daarom zonder merge; er gaat niets verloren.
Pull request closed