Irreversible Migration in Alembik

Not all database migrations are reversible. When using Alembic + SQLAlchemy, is there a (canonical) way to "tag" my downgrade / migration function so that it cannot be undone?

Compare ActiveRecord migrations, where you can raise ActiveRecord::IrreversibleMigration with the down method to signal this.

Did an exception (any exception) donwgrade in donwgrade to lower the failure rate "cleanly"?

+5
source share
1 answer

The exception is enough. This will not lead to migration, and you can never return.

 def downgrade(): raise Exception("Irreversible migration") 
+3
source

Source: https://habr.com/ru/post/1211885/


All Articles