You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If i have multiple new migrations and I execute up, are they executed as one atomic operation? i.e. if one migration fails, will other migrations be reverted?
---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/37601084-question-is-execution-of-multiple-migrations-atomic?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github).
The text was updated successfully, but these errors were encountered:
No. This is also a bit more complicated than you think.
You have to think of many things that can actually happen and would need to reverse, this begins on the migration that fails. The biggest problem actually is that transactions of many RDBMS, e.g. MySQL, do only work for DML and not for DDL, that means that the reversal of the actual migration would need to reverse on a potentially on an incomplete migration. There might be some easy cases to reverse this actually, like dropping a table that should have been created and ignoring if it has not been created. But there are many other cases, in fact some operations are not just safely reversable without transactions. In the case of transactions that work for DDL this is not that much of a problem anymore. However as stated, many RDBMS do not support this.
Anyhow, to come back to your question:
No, and there is no reason for them to be. A migration is atomic itself. That means every single migration is surrounded by a transaction, for some DBs this would result in resetting the transaction on a failure while this migration. A set of migrations should however not be atomic, that does not make any sense to be a default behavior. But it could possibly introduced via an optional setting, that might be named rollbackOnFailure: true or something like that.
I do see where you would see a benefit for this feature, I suspect you're looking for programmatic migrations and want to go back to the old state on failure I guess? In this case this really could be helpful though. I consider this as a feature request as of now :)
If i have multiple new migrations and I execute
--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/37601084-question-is-execution-of-multiple-migrations-atomic?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F73887&utm_medium=issues&utm_source=github).up
, are they executed as one atomic operation? i.e. if one migration fails, will other migrations be reverted?The text was updated successfully, but these errors were encountered: