Run Migrations Outside of a Transaction

Learn how to run a migration outside of a transaction environment.

Disable transactional behavior

By default, migrations are run within a database transaction. This is a good thing. If any part of our migration has an error, we can be assured that the database will be restored back to the way it was. There may be times when we won’t want to do it this way, though. In those cases, we can disable the transactional behavior by setting the module attribute @disable_ddl_transaction to true, like so.

Get hands-on with 1200+ tech skills courses.