I have a spring boot base project built as a jar. This jar base-0.0.1-SNAPSHOT.jar
file has flyway migration scripts in db/migration/*.sql
This base-0.0.1-SNAPSHOT.jar
is added as dependency in impl-0.0.1-SNAPSHOT-boot.jar
. Again, this impl boot jar is having flyway migration in db/migration/*.sql
.
The base jar's flyway migration creates the table and the impl boot jar alters the same table created by base jar.
In this scenario I need base jar's flyway scripts to be run first and then impl boot jar has to be followed,
Migration scripts in base jar
db/migration/v1__create.sql,
db/migration/v2__create.sql
Migration scripts in impl jar
db/migration/v3__create.sql
While mvn clean install
of impl jar, I am getting this error
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException: Migration V3__create.sql failed ------------------------------- SQL State : 42S02 Error Code : 42102 Message : Table "BASE_TABLE" not found; SQL statement:
I have added migration scripts in the base jar package, but still the base jar's flyway scripts are not executed.
How to execute the base package flyway script first and then impl boot jar's next during mvn build of impl boot jar.?
Update 1:
The base jar is packaged as part of another spring boot application by below plugin,
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <executions> <execution> <goals> <goal>jar</goal> </goals> <phase>package</phase> <configuration> <classifier>com</classifier> <includes> <include>**/entities/*</include> <include>**/services/*</include> <include>${basedir}/src/main/resources/db/migration/*</include> </includes> </configuration> </execution> </executions> </plugin>
The pom.xml of impl jar has
<dependency> <groupId>com.group</groupId> <artifactId>base</artifactId> <version>0.0.1-SNAPSHOT</version> <classifier>com</classifier> </dependency>
In Both the poms there is nothing related to flyway migration configuration mentioned. By default it used default flyway configuration.