Reputation: 1499
So, I just read and learnt about migrations in Flyway
.
I developed a spring-boot
project and included Flyway
in the projects POM file.
Now I wrote a SQL
script in a file and put it in the resources/db
folder of the project and Flyway
seems to do its job.
Sadly the SQL
script has some errors and the project won't compile. Instead it gives me a SQL
error. After that i change my SQL
script and resolved my errors. When I run the same project it now throws an error saying that validation checksum failed
. I checked back the flyway_schema_history
and it shows me the previous run script.
Shouldn't Flyway
store only those migrations which are correct and run properly? Because if by mistake I have some errors in a SQL
script, i will have to make one script and copy my corrected SQL
code in that and run it. Is there anything like this present in Flyway
?
Upvotes: 1
Views: 3322
Reputation: 1064
Flyway
s purpose is to control the versions of your database. This is only possible with the help of strict versioning rules, like every published version gets stored with a matching checksum. Once a version is published, it cannot just be deleted or manipulated because this would effect the database status.
The validation checksum failed
error Flyway
prints you is exactly the effect of manipulating an existing and versioned SQL file.
However - there are some options to revert the faulty SQL file:
So go ahead and invoke
flyway undo
This will give you the following result:
Database: jdbc:h2:file:./foobardb (H2 1.4) Current version of schema "PUBLIC": 2 Undoing migration of schema "PUBLIC" to version 2 - Add people Successfully undid 1 migration to schema "PUBLIC" (execution time 00:00.030s)
(https://flywaydb.org/getstarted/undo#undoing-the-last-migration)
Upvotes: 1