miguelgrinberg / Flask-Migrate

SQLAlchemy database migrations for Flask applications using Alembic
MIT License
2.37k stars 229 forks source link

New migrations automatically drops cascade constraint #477

Closed rlleshi closed 2 years ago

rlleshi commented 2 years ago

Whenever I make a new migration flask migrate somehow detects the cascade constraint of any property in the database as a change and proceeds to drop it in the migration file.

It drops & recreates the foreign key, thus removing the cascade constraint.

miguelgrinberg commented 2 years ago

Flask-Migrate does not create migrations, it just provides the integration with Flask. This discussion belongs in Alembic.

I believe you are confusing SQLAlchemy-level constraints, which do not need to be preserved in migration files, with database-level constraints, which do. But you may want to ask over in the Alembic project if you have any concerns or anything isn't working.