Last active
June 7, 2018 11:24
-
-
Save ryangardner/459a6040226b83297b554cebdc231fd8 to your computer and use it in GitHub Desktop.
generate db with flyway, jooq codegen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.foo.something</groupId> | |
<artifactId>dms-rds-schema</artifactId> | |
<version>0.0.5-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>dms-rds-schema</name> | |
<description>database schema for dms reports</description> | |
<parent> | |
<groupId>com.foo.something</groupId> | |
<artifactId>the-parent</artifactId> | |
<version>0.0.5-SNAPSHOT</version> | |
<relativePath>../</relativePath> | |
</parent> | |
<properties> | |
<db.password>db-password</db.password> | |
<db.username>db-user</db.username> | |
<db.database>db-testdb</db.database> | |
<db.schema>public</db.schema> <!-- jenkins needs 172.17.0.1 for the IP --> | |
<db.url>jdbc:postgresql://${docker.host.address}:${pg-database.port},172.17.0.1:${pg-database.port},${docker.host.address}:${pg-database.port}/${db.database}</db.url> | |
</properties> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>io.fabric8</groupId> | |
<artifactId>docker-maven-plugin</artifactId> | |
<version>0.25.2</version> | |
<executions> | |
<execution> | |
<id>start-db</id> | |
<goals> | |
<goal>start</goal> | |
</goals> | |
<phase>generate-sources</phase> | |
</execution> | |
<execution> | |
<id>stop-db</id> | |
<goals> | |
<goal>remove</goal> | |
</goals> | |
<phase>compile</phase> | |
</execution> | |
</executions> | |
<configuration> | |
<images> | |
<image> | |
<name>postgres:9.6.8</name> | |
<alias>pg-database</alias> | |
<run> | |
<ports> | |
<port>pg-database.port:5432</port> | |
</ports> | |
<env> | |
<POSTGRES_USER>${db.username}</POSTGRES_USER> | |
<POSTGRES_PASSWORD>${db.password}</POSTGRES_PASSWORD> | |
<POSTGRES_DB>${db.database}</POSTGRES_DB> | |
</env> | |
<wait> | |
<log>(?s)database system is ready to accept connections.*database system is ready to accept connections</log> | |
<time>20000</time> | |
</wait> | |
</run> | |
</image> | |
</images> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.flywaydb</groupId> | |
<artifactId>flyway-maven-plugin</artifactId> | |
<version>${flyway.version}</version> | |
<!-- Note that we're executing the Flyway | |
plugin in the "generate-sources" phase --> | |
<executions> | |
<execution> | |
<phase>generate-sources</phase> | |
<goals> | |
<goal>migrate</goal> | |
</goals> | |
</execution> | |
</executions> | |
<!-- Note that we need to prefix the db/migration | |
path with filesystem: to prevent Flyway | |
from looking for our migration scripts | |
only on the classpath --> | |
<configuration> | |
<url>${db.url}</url> | |
<user>${db.username}</user> | |
<password>${db.password}</password> | |
<locations> | |
<location>filesystem:src/main/resources/db/migration</location> | |
</locations> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.jooq</groupId> | |
<artifactId>jooq-codegen-maven</artifactId> | |
<version>${jooq.version}</version> | |
<!-- The jOOQ code generation plugin is also | |
executed in the generate-sources phase, | |
prior to compilation --> | |
<executions> | |
<execution> | |
<phase>generate-sources</phase> | |
<goals> | |
<goal>generate</goal> | |
</goals> | |
</execution> | |
</executions> | |
<configuration> | |
<jdbc> | |
<driver>org.postgresql.Driver</driver> | |
<url>${db.url}</url> | |
<user>${db.username}</user> | |
<password>${db.password}</password> | |
</jdbc> | |
<generator> | |
<database> | |
<name>org.jooq.util.postgres.PostgresDatabase</name> | |
<schemaVersionProvider>SELECT :schema_name || '_' || MAX("version") FROM | |
"flyway_schema_history" | |
</schemaVersionProvider> | |
<includes>.*</includes> | |
<excludes>flyway_schema_history</excludes> | |
<schemata> | |
<schema> | |
<inputSchema>${db.schema}</inputSchema> | |
<outputSchemaToDefault>true</outputSchemaToDefault> | |
</schema> | |
</schemata> | |
<customTypes> | |
<customType> | |
<name>com.foo.db.jooq.PostgresJsonBinder</name> | |
<type>com.fasterxml.jackson.databind.JsonNode</type> | |
<binding>com.foo.db.jooq.PostgresJsonBinder</binding> | |
</customType> | |
</customTypes> | |
<forcedTypes> | |
<forcedType> | |
<userType>com.fasterxml.jackson.databind.JsonNode</userType> | |
<binding>com.foo.db.jooq.PostgresJsonBinder</binding> | |
<!--<expression>.*original_record</expression>--> | |
<types>.*jsonb</types> | |
</forcedType> | |
</forcedTypes> | |
</database> | |
<generate> | |
<deprecated>false</deprecated> | |
<pojos>true</pojos> | |
<immutablePojos>true</immutablePojos> | |
</generate> | |
<target> | |
<packageName>com.foo.something</packageName> | |
<directory>target/generated-sources/jooq</directory> | |
</target> | |
</generator> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
<dependencies> | |
<dependency> | |
<groupId>org.postgresql</groupId> | |
<artifactId>postgresql</artifactId> | |
<version>42.2.2</version> | |
<!-- whoever uses this module is responsible for getting their own db driver --> | |
<optional>true</optional> | |
</dependency> | |
<dependency> | |
<groupId>org.jooq</groupId> | |
<artifactId>jooq-meta</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.jooq</groupId> | |
<artifactId>jooq</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>com.fasterxml.jackson.core</groupId> | |
<artifactId>jackson-databind</artifactId> | |
<version>2.9.5</version> | |
</dependency> | |
<dependency> | |
<groupId>org.slf4j</groupId> | |
<artifactId>slf4j-api</artifactId> | |
</dependency> | |
</dependencies> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment