I have project where I'm using SQLAlchemy for models and I'm trying to integrate Alembic for making migrations. Everything works as expected when I change models and Alembic sees that models have changed -> it creates good migration file with command:
alembic revision --autogenerate -m "model changed"
But when I have NOT changed anything in models and I use the same command:
alembic revision --autogenerate -m "should be no migration"
revision gives me 'empty' revision file like this:
"""next
Revision ID: d06d2a8fed5d
Revises: 4461d5328f57
Create Date: 2021-12-02 18:09:42.208607
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd06d2a8fed5d'
down_revision = '4461d5328f57'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
What is purpose of this file? Could I prevent creation of this 'empty file' when alembic revision --autogenerate will not see any changes? To compare when I use Django and it's internal migration when I type command:
python manage.py makemigrations
I get output something like:
No changes detected
and there is not migration file created. Is there a way to do the same with Alembic revision? Or is there other command that could check if there were changes in models and if there were then I could simply run alembic revision and upgrade?