Skip to content

Integrate alembic check into CI to check for model changes without a matching migration #48998

@ashb

Description

@ashb

Body

Since Alembic 1.9 it has had a built in command to check if there are changes to the models that don't have a migration: https://alembic.sqlalchemy.org/en/latest/autogenerate.html#alembic-check

When developing code it’s useful to know if a set of code changes has made any net change to the database model, such that new revisions would need to be generated. To automate this, Alembic provides the alembic check command. This command will run through the same process as alembic revision --autogenerate, up until the point where revision files would be generated, however does not generate any new files. Instead, it returns an error code plus a message if it is detected that new operations would be rendered into a new revision, or if not, returns a success code plus a message. When alembic check returns a success code, this is an indication that the alembic revision --autogenerate command would produce only empty migrations, and does not need to be run.

We should add this somewhere in our CI pipeline. We've already got some CI jobs that do upgrade and downgrade, adding this to that workflow seems like a good idea

Committer

  • I acknowledge that I am a maintainer/committer of the Apache Airflow project.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions