I want to use flyway to generate a migration script for a db, then use jooq to generate code based on said database, and finally use that model to deploy onto an h2 file db.
I ran mvn clean install and see that a db file was created.
However, when running mvn flyway:info, I see the migrations are pending:
[INFO] +-----------+---------+---------------+------+--------------+---------+----------+
| Category | Version | Description | Type | Installed On | State | Undoable |
+-----------+---------+---------------+------+--------------+---------+----------+
| Versioned | 1 | create tables | SQL | | Pending | No |
| Versioned | 2 | book | SQL | | Pending | No |
+-----------+---------+---------------+------+--------------+---------+----------+
So I then ran mvn flyway:migrate and see they are apparently migrated:
[INFO] +-----------+---------+---------------+------+---------------------+---------+----------+
| Category | Version | Description | Type | Installed On | State | Undoable |
+-----------+---------+---------------+------+---------------------+---------+----------+
| Versioned | 1 | create tables | SQL | 2024-03-18 22:01:31 | Success | No |
| Versioned | 2 | book | SQL | 2024-03-18 22:01:31 | Success | No |
+-----------+---------+---------------+------+---------------------+---------+----------+
Now, however, when I try to run mvn clean install -DskipTests, I am still not getting my generated code. I am using "testcontainers-jooq-codegen-maven-plugin" and my pom looks like this:
<properties>
<java.version>17</java.version>
<flyway-maven-plugin.version>10.7.1</flyway-maven-plugin.version>
<database.user>sa</database.user>
<database.url>jdbc:h2:file:./testdb</database.url>
<database.password>password</database.password>
<jooq.version>3.18.13</jooq.version>
<flyway.cleanDisabled>false</flyway.cleanDisabled>
<h2.version>2.1.214</h2.version>
<testcontainers.version>1.19.1</testcontainers.version>
<testcontainers-jooq-codegen-maven-plugin.version>0.0.2</testcontainers-jooq-codegen-maven-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jooq</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jooq</artifactId>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-jooq-codegen-maven-plugin</artifactId>
<version>${testcontainers-jooq-codegen-maven-plugin.version}</version>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.6.0</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>generate-jooq-sources</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<database>
<type>POSTGRES</type>
<containerImage>postgres:15.3-alpine</containerImage>
</database>
<flyway>
<defaultSchema>PUBLIC</defaultSchema>
<createSchemas>true</createSchemas>
<locations>
filesystem:src/main/resources/db/migration
</locations>
</flyway>
<jooq>
<generator>
<database>
<includes>.*</includes>
<excludes>flyway_schema_history</excludes>
<inputSchema>public</inputSchema>
</database>
<target>
<!-- <packageName>example.micronaut.jooq</packageName>-->
<!-- <directory>target/generated-sources/jooq</directory>-->
<packageName>example.micronaut.jooqtest</packageName>
<directory>src/main/java</directory>
</target>
</generator>
</jooq>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/jooq</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>10.10.0</version>
<executions>
<execution>
<id>flyway-migrate</id>
<phase>generate-sources</phase>
<goals>
<goal>migrate</goal>
</goals>
</execution>
</executions>
<configuration>
<user>${database.user}</user>
<password>${database.password}</password>
<url>${database.url}</url>
<password>${database.password}</password>
<locations>
<location>classpath:db/migration</location>
</locations>
</configuration>
</plugin>
</plugins>
</build>
Update
What is wrong with my configuration? I have a basic script V1__create_tables inside db.migrations.
Once, the code was actually generated in the right directory, but when I reran "mvn clean install", it was cleared and since then I have been unable to reproduce it.
I feel like I'm hitting my ahead against a wall so far.