New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update #6791 "AR::Migrator.bulk_migration option" #11530
Conversation
@Empact could you rebase this? |
040456d
to
e2859bd
Compare
Done - incidentally I noticed some more defunct ivars, a total of 4, so I removed them in a separate commit. |
@Empact sorry about the back and forth - looks like this is already supported unless explicitly disabled by the migration? |
@tamird No this is not currently supported - currently each migration is run in a transaction, unless disable_ddl_transaction! is called, but if you run several migrations, there's no way to cleanly roll back them all if a single migration fails. This feature is useful for deploys in that you can ensure that no database changes occur if any of your migrations fail. This would mean you could have a truly clean rollback to the pre-deploy state, rather than have some data changes persist even if you roll back your code changes in response to a migration failure. |
Hmm. I think I disagree with this change - it feels natural to me to expect each migration to be atomic but extending atomicity to the group of transactions that happen to run in the same invocation feels surprising and even sloppy to me. 👍 on the drive-by cleanups you found though, would be good to open a separate PR for them so that this discussion doesn't prevent their inclusion. |
e2859bd
to
5a7479a
Compare
Ok closing based on your comments here, and @rafaelfranca's comment on #6791 Extracted the ivars commit to #17092 |
This sounds quite desirable to me; if half the migrations run and then one fails, neither the previously-deployed nor currently-checked-out code can be expected to work with the resulting database. In sufficiently merge-ful conditions, there may in fact be no intermediate commit that had this set of migrations. However, I think a migration that's explicitly opted out of a transaction should still have its wishes honoured. If we can arrange that, without too badly contorting things, then I'm 👍 to merge (and, personally, use) this option. |
@matthewd I may take the time to extract it as a gem. Will post back here if I do. |
@Empact if you can fix the behaviour for migrations that have explicitly disabled the surrounding transaction, I'll merge it: it sounds desirable to me, and while that opinion doesn't seem universal, I haven't seen any objections to it being a non-default option. |
@matthewd Does this line do what you're thinking?: |
I guess I was imagining that the "ideal" interpretation would be to still cluster transaction-able migrations together. So:
But yeah, fallback to the current behaviour sounds quite defensible... and much simpler to implement. 😄 |
We could print a message when a ddl-disabled migration leads to the run being run individually. |
+1, @Empact thanks for renewing this one |
Enables running migration under same DDL transaction if supported by database
5a7479a
to
b74297a
Compare
Does anyone have plans to follow up on this? If not, perhaps we should close the issue. |
This update #6791 and integrates it with the
disable_ddl_transaction!
option that was added since the PR was first opened.Could probably use some additional testing to handle the interplay between these two features.