I have been working on a project including SQLite, SQLAlchemy, and Alembic.
My current task is to write a test to ensure that our migrations and the SQLAlchemy models are in sync.
I happily found that there was introduced a new built-in command just for that in Alembic==1.9.0. https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4295 https://alembic.sqlalchemy.org/en/latest/api/commands.html#alembic.command.check
from alembic.command import check, upgrade
from alembic.config import Config
# pytest
def test_migrations_and_sqlalchelmy_models_are_in_sync():
config = Config(CONFIG_PATH)
upgrade(config, "head")
check(config)
It's nice. And it works fine until it comes to the names of constraints (tried with sqlalchemy.UniqueConstraint
and sqlalchemy.ForeignKeyConstraint
). For some reason, which is unknown to me, it does not detect difference between the names of a constraint.
Is it intented to detect the difference in the name of a constraint? Is there any way to fix this?
Versions:
python==3.10.6
sqlalchemy==1.4.23
alembic==1.9.0