We use the Flyway Gradle plugin to do our migrations offline (i.e. we migrate while the system is down). We recently upgraded to Flyway 5.0.7 and we see this warning now for migrations:
Could not find schema history table XXXXXXX
.flyway_schema_history
, but found XXXXXXX
.schema_version
instead. You are seeing this message because Flyway changed its default for flyway.table in version 5.0.0 to flyway_schema_history and you are still relying on the old default (schema_version). Set flyway.table=schema_version in your configuration to fix this. This fallback mechanism will be removed in Flyway 6.0.0.
(I've used the XXXXXXX to obscure the actual schema name).
So, it appears that we can avoid the error by setting flyway.table=schema_version. But, it also says this mechanism will be removed in Flyway 6.0.0.
Are we supposed to do something to make this compatible going forward? Do we have to manually rename the schema_version table to flyway_schema_history? Or is there a way to make Flyway do it? If not, what is going to happen when Flyway 6.0.0 comes out? Will it automatically migrate the data to the appropriate table name?
The default for
flyway.table
has been changed fromschema_version
toflyway_schema_history
. And they have also provided automatic fallback to old default with a warning to avoid breaking existing installations using the old default.It means from flyway 5, If you do not specify
flyway.table
property inside your configuration file, then flyway will look for the tableflyway_schema_history
in db, and if not found it will look for the tableschema_version
as a fallback and if the old table is found then will warn with the message that you are getting now. From flyway 6, this fallback mechanism will be removed. If you do not provideflyway.table
property, it will look forflyway_schema_history
in db, if not found it will not look forschema_version
table even if you have any and will create a new table namedflyway_schema_history
to maintain functionality.In flyway 6, your existing system will run fine if you set
flyway.table=schema_version
, you do not need to change table name in db. But if you do not set the property, then you must have to change the table name, otherwise flyway will not recognize existing schema_version table, will treat the system as a new one, will create flyway_schema_history table and will start executing scripts from start.Hoping it will help.
It is possible to migrate from schema_version to flyway_schema_history by mapping a table over the other and copying the relevant records:
This is the schema version of flyway_schema_history as of flyway 5.2.2. I recommend, to use this script safely, to migrate before to this version and then move forward.
Please, understand that this script must be executed as it is in your db console. This script is for MySQL only. You have to craft your own for other databases.
On PostgreSQL I have solved it with just one migration on top:
It works actually in 2 stages: