Reputation: 4111
I am using spring boot with default configuration with flyway and hibernate. I'm wondering about the execution order.
According to the documentation Flyway checks the version of the database and applies new migrations automatically before the rest of the application starts.
Where can I find a source code confirming that statement? Where execution order is determined?
Upvotes: 1
Views: 465
Reputation: 2817
Spring boot use a FlywayMigrationInitializer
bean ( which implements InitializingBean
with a high order ( oder = 0 ) ), so that afterPropertiesSet which contains the flyway migration function :
@Override
public void afterPropertiesSet() throws Exception {
if (this.migrationStrategy != null) {
this.migrationStrategy.migrate(this.flyway);
}
else {
this.flyway.migrate();
}
}
will execute the logic inside Flyway.java#migrate()
which
Starts the database migration. All pending migrations will be applied in order.Calling migrate on an up-to-date database has no effect.
You can refer to the Flyway.java of javadoc and FlywayMigrationInitializer.java javadoc
Upvotes: 2