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

Undo followed by repair leads to corrupted schema history #2219

Closed
froudj opened this issue Nov 28, 2018 · 1 comment
Closed

Undo followed by repair leads to corrupted schema history #2219

froudj opened this issue Nov 28, 2018 · 1 comment

Comments

@froudj
Copy link

froudj commented Nov 28, 2018

Which version and edition of Flyway are you using?

5.2.3 pro

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Command-line

Which database are you using (type & version)?

H2 1.4.197

Which operating system are you using?

Windows 7 Pro SP1

What did you do?

Settings:
flyway.outOfOrder=true

Starting with an empty history table and only 2 sql files:
V1.1__hello.sql

select 'do' from dual;

U1.1__hello.sql

select 'undo' from dual;

flyway migrate

Flyway Pro Edition (10 schemas) 5.2.3 by Boxfuse licensed to ╔tat de GenÞve (DGSI) until 2019-07-01
Database: jdbc:h2:tcp://localhost/~/test (H2 1.4)
Successfully validated 3 migrations (execution time 00:00.012s)
Current version of schema "PUBLIC": 1
outOfOrder mode is active. Migration of schema "PUBLIC" may not be reproducible.
Migrating schema "PUBLIC" to version 1.1 - hello
+------+
| 'do' |
+------+
| do   |
+------+

Successfully completed migration of schema "PUBLIC" to version 1.1 - hello
Successfully applied 1 migration to schema "PUBLIC" (execution time 00:00.034s)

flyway undo

Flyway Pro Edition (10 schemas) 5.2.3 by Boxfuse licensed to ╔tat de GenÞve (DGSI) until 2019-07-01
Database: jdbc:h2:tcp://localhost/~/test (H2 1.4)
Current version of schema "PUBLIC": 1.1
Undoing migration of schema "PUBLIC" to version 1.1 - hello
+--------+
| 'undo' |
+--------+
| undo   |
+--------+

Successfully undid 1 migration to schema "PUBLIC" (execution time 00:00.029s)

I changed the content of V1.1__hello.sql

flyway repair

Flyway Pro Edition (10 schemas) 5.2.3 by Boxfuse licensed to ╔tat de GenÞve (DGSI) until 2019-07-01
Database: jdbc:h2:tcp://localhost/~/test (H2 1.4)
Repair of failed migration in Schema History table "PUBLIC"."flyway_schema_history" not necessary. No failed migration detected.
Repairing Schema History table for version 1.1 (Description: hello, Type: SQL, Checksum: 35419354)  ...
Successfully repaired schema history table "PUBLIC"."flyway_schema_history" (execution time 00:00.019s).
Manual cleanup of the remaining effects the failed migration may still be required.

flyway migrate

Flyway Pro Edition (10 schemas) 5.2.3 by Boxfuse licensed to ╔tat de GenÞve (DGSI) until 2019-07-01
Database: jdbc:h2:tcp://localhost/~/test (H2 1.4)
Successfully validated 4 migrations (execution time 00:00.021s)
Current version of schema "PUBLIC": 1.1
outOfOrder mode is active. Migration of schema "PUBLIC" may not be reproducible.
Schema "PUBLIC" is up to date. No migration necessary.
+-----------+---------+-----------------------+----------+---------------------+--------------+----------+
| Category  | Version | Description           | Type     | Installed On        | State        | Undoable |
+-----------+---------+-----------------------+----------+---------------------+--------------+----------+
|           | 1       | << Flyway Baseline >> | BASELINE | 2018-11-28 11:04:57 | Baseline     | No       |
| Versioned | 1.1     | hello                 | SQL      | 2018-11-28 11:22:07 | Success      | Yes      |
| Versioned | 1.1     | hello                 | SQL      | 2018-11-28 11:26:17 | Out of Order | Yes      |
+-----------+---------+-----------------------+----------+---------------------+--------------+----------+

flyway undo (3 times)

What did you expect to see?

No corrupted table

What did you see instead?
Flyway Pro Edition (10 schemas) 5.2.3 by Boxfuse licensed to ╔tat de GenÞve (DGSI) until 2019-07-01
Database: jdbc:h2:tcp://localhost/~/test (H2 1.4)
Corrupted schema history: multiple undo entries for version 1.1
@axelfontaine axelfontaine added this to the Flyway 5.2.4 milestone Nov 28, 2018
@axelfontaine axelfontaine changed the title Undo & repair leads to: Corrupted schema history Undo followed by repair leads to corrupted schema history Nov 30, 2018
axelfontaine pushed a commit to flyway/flywaydb.org that referenced this issue Nov 30, 2018
@axelfontaine
Copy link
Contributor

Thanks for the detailed report and the investigation. This was very helpful in identifying the issue! Fixed.

dohrayme pushed a commit to dohrayme/flyway that referenced this issue Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants