Jeremy Jarrell
Jeremy Jarrell

Reputation: 679

Manually update schema_version table in Flyway

I've renamed some previously created migration files and would like to update Flyway's schema_version table to contain the new names for migrations which have already been applied.

I attempted to create a migration that simply updates the affected rows in the schema_version table, but running this migration causes the migration process to hang since the schema_version table is locked.

Is there a way to update data in the schema_version table using a migration?

I'm using MySQL.

Upvotes: 0

Views: 3322

Answers (2)

Alex
Alex

Reputation: 1639

You can place the required SQL in a beforeValidate.sql file:

UPDATE schema_version
SET script = 'new_name'
WHERE script = 'old_name'

There's one caveat: the above fails when schema_version table doesn't exist yet on a clean environment. This can be solved by using Java FlywayCallbacks where you have more control over error handling.

Upvotes: 1

Axel Fontaine
Axel Fontaine

Reputation: 35169

No. It is always locked. This is part of the mechanics to prevent multiple competing nodes from migrating the DB in parallel.

Upvotes: 1

Related Questions