-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change DB migration logic to have one transaction per migrations script
Executing all migrations in one big transaction is problematic as due to a few Postgres limitations. For example, `alter type ... add value` does add a value to an enum, but that new value cannot be used until the transaction has been committed. But this is something migrations regularly do. Previously we solved this by copying the type, adjusting the new one, replacing the old with the new. But that doesn't work as easily anymore now since functions depend on the type. Having one transaction per migration should be totally fine. We will a migration plan more often, but the wasted work is pretty irrelevant. By making a plan each time, we still make sure that we apply the next required migration, even when multiple Tobira nodes doing all this at the same time. So yeah, as far as I can tell, there is still zero chance for DB corruption, every migration will be executed exactly once (by whatever process) and processes should still not deadlock.
- Loading branch information
1 parent
3d1d057
commit 5fc735f
Showing
2 changed files
with
57 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters