Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing to Sqitch, does Flyway have the ability to run verification and revert scripts?

Tags:

flyway

Sqitch has the ability to run Revert and Verification scripts. Does or are their plans for Flyway to support such abilities?

like image 366
Brady Clifford Avatar asked May 11 '17 16:05

Brady Clifford


People also ask

What is Flyway validate?

Validate helps you verify that the migrations applied to the database match the ones available locally. This is very useful to detect accidental changes that may prevent you from reliably recreating the schema. Validate works by storing a checksum (CRC32 for SQL migrations) when a migration is executed.

How does Flyway migration work?

How Does Flyway Work? Flyway works by checking the current version of the database and by applying new migrations automatically before the rest of the application starts.

Can Flyway migrate data?

Flyway is an open-source database migration tool. It strongly favors simplicity and convention over configuration. It is based around just 7 basic commands: Migrate, Clean, Info, Validate, Undo, Baseline and Repair.


1 Answers

I'm unfamiliar with the capabilities of Sqitch, but I can briefly explain what's possible with Flyway.

Flyway does have support for revert scripts, via the Undo command. The process works by allowing you to specify an 'Undo migration' alongside a standard migration script. The Undo migration knows how to revert the changes specified in the standard migration script. Note that this is a Pro feature only.

Undo migrations do not work for Repeatable Migrations, which are used mainly for Views, procedures, and so on. These should just be amended and then migrated normally.

Flyway also allows you to verify your migrations to a certain extent with the Validate command. Validate checks that the migrations applied to the database match the migrations in your project.

From briefly looking through the Sqitch docs, it looks like their verification feature allows you to specify a script for each migration to see if it makes sense to run it. Flyway doesn't natively support such a process. However, since the migration scripts are just plain SQL, nothing stops you from manually including such verification logic in the migration scripts themselves.

As a potential alternative, you could use the Dry Run feature, which produces the script which will ultimately be used to migrate the database. You could execute the Dry Run script against a test environment to see if the deployment would succeed. Dry Run is also a Pro feature.

I hope that helps.

Thanks

Mikiel

like image 76
Mikiel Avatar answered Sep 21 '22 16:09

Mikiel