Reputation: 313
In my Java application I have set:
flyway.setBaselineVersionAsString("7")
however on a brand new database which doesn't yet have the schema_version
table Flyway doesn't consider the baseline setting and runs all migrations.
Is there a way to force the creation of schema_version
table before migrations start, as I tried to create the table manually and the code worked fine. Or is there any other solution for that problem?
Upvotes: 2
Views: 7578
Reputation: 21
I have been in this kind situation too many times. the way I do is detect the result of flyway.info(). If it is null, it means the schema has objects but no "schema_version" table - then set the baseline like you did.
Upvotes: 0
Reputation: 7309
Which command are you running, baseline
or migrate
?
If you are running baseline
then you need to publish more configuration in order to establish what is wrong - as creating a schema_version
table with a basline version is exactly what it does.
If you are running migrate
the observed behaviour is correct - that is, on a non-Flyway managed database the schema_version
table will be created and all migrations run. The one exception to this is if you have set baselineOnMigrate
which will effectively run an implicit baseline
before the migrate
is started.
Creating the schema_version
yourself is certainly something you should not be doing, you will completely compromise Flyways intelligence.
Upvotes: 1