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

ValidateOnMigrate should fail for unapplied migration when outOfOrder=false #1363

Closed
PeeZu opened this issue Jul 13, 2016 · 8 comments
Closed

ValidateOnMigrate should fail for unapplied migration when outOfOrder=false #1363

PeeZu opened this issue Jul 13, 2016 · 8 comments

Comments

@PeeZu
Copy link

@PeeZu PeeZu commented Jul 13, 2016

What version of Flyway are you using?

4.1 via ANT (also tested in 4.3 => same behaviour)

What database are you using (type & version)?

Oracle 11.2.0.4

What operating system are you using?

Windows 7

What did you do?

(Please include the content causing the issue, any relevant configuration settings, and the command you ran)

When we try to migrate with property flyway.validateOnMigrate=true, Flyway doesn't detect not applied migration:

Step to reproduce:

  1. Create migrations files: V1.0_foo.sql + V2.0_bar.sql
  2. run 'migrate' command
  3. Create migration file: V1.1_foo.sql
  4. run 'validate' command => Validate failed: Detected resolved migration not applied to database: 1.1 => Expected
  5. run 'migrate' command with flyway.validateOnMigrate=true
What did you expect to see?

Same as step 4 above: Validate failed: Detected resolved migration not applied to database: 1.1

Action to do:
Migrate should be run with flyway.outOfOrder=true

What did you see instead?

Schema "XXXX" is up to date. No migration necessary.

@rainoko
Copy link

@rainoko rainoko commented Nov 9, 2016

same behavior in v4.01 and v4.0.3
didnt try v4.0.2

is it possible to fix it in 4.0.x version?

@mmuth
Copy link

@mmuth mmuth commented Nov 29, 2016

We have the same issue with v4.0.3.
It's a pity that it doesn't detect the unapplied migrations, because it is one of the core features of Flyway...

@jkuipers
Copy link
Contributor

@jkuipers jkuipers commented Dec 12, 2016

I just encountered this with v4.0.3 as well. This is a very serious bug, as it means that the guarantees Flyway is supposed to provide no longer hold. We ran into this when someone had forgotten to merge a migration to a release branch, so it only showed up later after newer migrations had already been applied.
We have not enabled out-of-order, so Flyway should detect that there's an unapplied migration file that can no longer be applied, but it simply ignores the file.

Right now the code in MigrationInfoImpl#validate only performs the check to detect the IGNORED migration if context.pending is false. That is apparently a bug, introduced by a bad refactoring in commit 88c06bb.
I've fixed that issue (after adding a failing test) and have issued a pull request.

@jkuipers
Copy link
Contributor

@jkuipers jkuipers commented Dec 12, 2016

BTW, this seems like a duplicate of #1364 (filed by the same user)

jkuipers added a commit to jkuipers/flyway that referenced this issue Dec 12, 2016
@mmuth
Copy link

@mmuth mmuth commented Dec 15, 2016

@jkuipers great! I hope it will be merged soon 👍

@PeeZu
Copy link
Author

@PeeZu PeeZu commented Dec 20, 2016

@jkuipers, thanks for the fix, work fine for #1363, but same issue occur on #1364

@mmuth
Copy link

@mmuth mmuth commented Jan 24, 2017

@axelfontaine what do you think about that Pull Request :) ??

axelfontaine added a commit that referenced this issue Jan 30, 2017
Fix for #1363 (and #1364) caused by broken refactoring in commit 88c0…
@axelfontaine axelfontaine changed the title ValidateOnMigrate issue ValidateOnMigrate should fail for unapplied migration when outOfOrder=false Jan 30, 2017
axelfontaine added a commit to flyway/flywaydb.org that referenced this issue Jan 30, 2017
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Jan 30, 2017

@jkuipers Thanks for the fix! Merged.

pradheeps pushed a commit to pradheeps/flyway that referenced this issue Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.