Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When would you want to use disable_ddl_transaction in Rails?

My understanding is that all migrations are wrapped in a transaction, meaning, if a change for 1 row, like adding null: false, in a table fails, every other row will fail. When would you not want this to happen with disable_ddl_transaction?

like image 770
mangocaptain1 Avatar asked Sep 06 '17 04:09

mangocaptain1


Video Answer


1 Answers

All migrations are wrapped in transaction by default so that they can be rolled back when they are failed.

You need to use disable_ddl_transaction when you want to do something that can not excute inside a transaction. You can check Transactional Migrations section of Migration document for example.

like image 177
Thanh Avatar answered Sep 19 '22 15:09

Thanh