Align Alembic metadata with models - #43
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4be036c519
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| sa.Column("title", sa.String(length=255), nullable=True), | ||
| sa.Column("description", sa.Text(), nullable=True), | ||
| sa.Column("click_count", sa.Integer(), nullable=False, server_default="0"), | ||
| sa.Column("click_count", sa.BigInteger(), nullable=False, server_default="0"), |
There was a problem hiding this comment.
Add a forward migration for the BigInteger change
In any database that has already run revision 0001_initial_schema, Alembic will see the revision as applied and will not re-run this edited initial migration. Those environments therefore keep the old links.click_count INTEGER column while the model now expects BigInteger, so high-traffic links can still overflow at the 32-bit integer limit and Alembic drift checks will continue reporting the type mismatch. Please add a new migration that alters existing schemas instead of relying only on the rewritten initial revision.
Useful? React with 👍 / 👎.
Motivation
alembic revision --autogenerateyields no unexpected drift.Baseto avoid inconsistent metadata and type/index mismatches.Description
migrations/env.pysotarget_metadata = Base.metadatais fully populated during autogenerate and keepcompare_type=Trueenabled.Basefromapp.database.baseinstead ofapp.database.migrations/versions/0001_initial_schema.pyto match the models (changelinks.click_counttoBigInteger, make indexes/unique constraints match the model-generated names and uniqueness, and add/remove indexes so names and properties align).Testing
DATABASE_URL=sqlite:///$tmp/test.db alembic upgrade head && DATABASE_URL=sqlite:///$tmp/test.db alembic check, andalembic checkreported "No new upgrade operations detected" indicating no drift.pass) for both attempts, indicating metadata/migration alignment.python -m compileall app migrationsand ran the test suite withpytest, where all tests passed (8 passed).Codex Task