Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Irreversible migrations in Alembic

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

Compare ActiveRecord migrations where you can raise ActiveRecord::IrreversibleMigration from your down method to signal this.

Would raising an exception (any exception) in donwgrade cause the downgrade to fail "cleanly"?

like image 498
vicvicvic Avatar asked Jan 25 '15 17:01

vicvicvic


1 Answers

An exception is enough. It will fail the migration and you will never be able to go back.

def downgrade():
    raise Exception("Irreversible migration")
like image 114
iurisilvio Avatar answered Sep 18 '22 17:09

iurisilvio