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

Make baseline() idempotent even after applying migrations #1345

Merged
merged 3 commits into from
Jan 31, 2017

Conversation

ferstl
Copy link
Contributor

@ferstl ferstl commented Jun 20, 2016

Baselining a second time after applying migrations threw an Exception even though the baseline version and description is the same. This PR allows executing the baseline command again after applying migrations as long as the baseline version and description do not change. In such a case the baseline command won't do anything.
This feature is especially useful in automated test environments where baselining or migrations might have taken place or not.

Before changing the DbBasline class, I wrote some unit tests to make sure that I don't accidentally break something. After changing the class I added some more tests for this new feature.

Baselining a second time after applying migrations threw an Exception
even though the baseline version and description didn't change.
This commit allows executing the baseline command again after applying
migrations as long as the baseline version and description do not
change.
@axelfontaine axelfontaine added this to the Flyway 4.1 milestone Jun 20, 2016
@axelfontaine axelfontaine changed the title Allow baselining after applying migrations Make baseline() idempotent even after applying migrations Jan 31, 2017
@axelfontaine axelfontaine merged commit 06cb47c into flyway:master Jan 31, 2017
axelfontaine pushed a commit to flyway/flywaydb.org that referenced this pull request Jan 31, 2017
@axelfontaine
Copy link
Contributor

Thanks for the pull request. I personally don't see the exact need for this. However I am all for making things idempotent and the change is rather small, so approved.

@ferstl
Copy link
Contributor Author

ferstl commented Jan 31, 2017

@axelfontaine For us it will be useful in test environments where we use Flyway to test db migrations on schemas with (almost) productive data. The test does basically set a baseline and applies new scripts. If the baseline was already set (because the test has already been executed once on that schema), the build crashed. With this fix we can remove the hacks we had to make to work around this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants