Domanda

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.

È stato utile?

Soluzione

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

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top