setup jooq and flyway for db mapping & migrations
This commit is contained in:
parent
3747ef33a4
commit
349cc7ec00
4 changed files with 81 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -40,4 +40,5 @@ build/
|
|||
.idea/
|
||||
|
||||
# mptv
|
||||
config.json
|
||||
config.json
|
||||
*.db
|
||||
66
pom.xml
66
pom.xml
|
|
@ -30,6 +30,35 @@
|
|||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.6.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JDBC -->
|
||||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<version>3.45.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
<version>10.11.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JOOQ -->
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq</artifactId>
|
||||
<version>3.19.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-meta</artifactId>
|
||||
<version>3.19.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-codegen</artifactId>
|
||||
<version>3.19.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
@ -40,6 +69,43 @@
|
|||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.2.5</version>
|
||||
</plugin>
|
||||
|
||||
<!-- JOOQ -->
|
||||
<plugin>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-codegen-maven</artifactId>
|
||||
<version>3.19.7</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>generate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
<configuration>
|
||||
<jdbc>
|
||||
<driver>org.sqlite.JDBC</driver>
|
||||
<url>jdbc:sqlite:mptv.db</url>
|
||||
</jdbc>
|
||||
|
||||
<generator>
|
||||
<database>
|
||||
<includes>*.</includes>
|
||||
<excludes>flyway_schema_history</excludes>
|
||||
</database>
|
||||
<generate>
|
||||
<records>true</records>
|
||||
</generate>
|
||||
<target>
|
||||
<packageName>com.mykola2312.mptv</packageName>
|
||||
<directory>target/generated-sources/jooq</directory>
|
||||
</target>
|
||||
</generator>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -3,6 +3,8 @@ package com.mykola2312.mptv;
|
|||
import com.mykola2312.mptv.config.Config;
|
||||
import com.mykola2312.mptv.ui.MainFrame;
|
||||
import org.apache.commons.cli.*;
|
||||
import org.flywaydb.core.Flyway;
|
||||
import org.flywaydb.core.api.configuration.Configuration;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
@ -36,5 +38,13 @@ public class Main {
|
|||
|
||||
MainFrame frame = new MainFrame();
|
||||
frame.create(config.frame);
|
||||
|
||||
Flyway flyway = new Flyway(
|
||||
Flyway.configure()
|
||||
.dataSource("jdbc:sqlite:mptv.db", "", "")
|
||||
.load()
|
||||
.getConfiguration()
|
||||
);
|
||||
flyway.migrate();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
3
src/main/resources/db/migration/V001.01__init.sql
Normal file
3
src/main/resources/db/migration/V001.01__init.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
CREATE TABLE test (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT
|
||||
);
|
||||
Loading…
Add table
Reference in a new issue