Skip to content
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

Support out of order migrations #29

Open
RoryQ opened this issue Jun 12, 2020 · 3 comments
Open

Support out of order migrations #29

RoryQ opened this issue Jun 12, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@RoryQ
Copy link

RoryQ commented Jun 12, 2020

What

Similar to FlywayDB outOfOrder option.

Allows migrations to be run "out of order".
If you already have versions 1 and 3 applied, and now a version 2 is found, it will be applied too instead of being ignored.

Why

Flexibility to apply a hotfix to production, then cherry-pick the migration back to development environments which are already ahead of production.

@110y
Copy link
Collaborator

110y commented Jul 19, 2020

@RoryQ

So sorry for late responding.

Flexibility to apply a hotfix to production, then cherry-pick the migration back to development environments which are already ahead of production.

It's interesting case which I've not thought so far.
In my case, I'm always apply migrations for development environments first even though it's for the hotfix.

Could you explain more specifically about the use case?

@RoryQ
Copy link
Author

RoryQ commented Jul 28, 2020

Yep, so to elaborate on the hotfix example. Consider the following timeline.

Release goes to production with a large table
migrations: ["001_create_large_table.sql"]
Production Version: 1

Development has already started and changes have been applied for new tables
migrations: ["001_create_large_table.sql", "002_new_feature.sql", "003_another_feature.sql"]
Development Version: 3

Then when users complain of slowness, or a critical bug is found. Then a hotfix is required for production. But what version number do we choose for the hotfix? If we choose 2:

migrations: ["001_create_large_table.sql", "002_hotfix_urgent_issue.sql"]
Production Version: 2

Then when we merge the hotfix back into the development environment then we have a clash between 002_new_feature.sql and 002_hotfix_urgent_issue.sql

So what if we anticipate the hotfix version in develop and choose 4?

migrations: ["001_create_large_table.sql", "004_hotfix_urgent_issue.sql"] Production Version: 4`

migrations: ["001_create_large_table.sql", "002_new_feature.sql", "003_another_feature.sql", "004_hotfix_urgent_issue.sql"]
Development Version: 4

Then the development environment works. But then there's a problem when we go to release these changes to production. The Version is now 4, migrations 002_new_feature.sql and 003_another_feature.sql won't be applied!

So the alternative is to apply the hotfix to the development environment as you said, then apply all those changes to production. This requires the migrations in the development environment to be backwards compatible with the production app code, and in a production ready state.

Having the flexibility here to apply only the hotfix to production and the remaining migrations at the appropriate time would be beneficial as it relives the burden of testing and verifying the out of scope migration scripts.

@RoryQ
Copy link
Author

RoryQ commented Sep 10, 2020

Hi, any update on this?

I have other improvements in my fork that I think the wider community will benefit from. I think it's best for the community if these improvements are available at the "source", avoiding unnecessary fragmentation.

Do you have concerns with the implementation? Or do you need help maintaining this project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants