initial commit
This commit is contained in:
1
db/.gitignore
vendored
Normal file
1
db/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
5
db/Dockerfile
Normal file
5
db/Dockerfile
Normal file
@ -0,0 +1,5 @@
|
||||
FROM openjdk:11
|
||||
|
||||
ARG version
|
||||
ADD target/test-db-${version}.jar /test-db.jar
|
||||
ENTRYPOINT ["java", "-jar", "/test-db.jar"]
|
56
db/pom.xml
Normal file
56
db/pom.xml
Normal file
@ -0,0 +1,56 @@
|
||||
<?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/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>test</groupId>
|
||||
<artifactId>parent</artifactId>
|
||||
<version>${revision}${sha1}${changelist}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>test-db</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>DB</name>
|
||||
|
||||
<properties>
|
||||
<main.class>test.DbApp</main.class>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>test</groupId>
|
||||
<artifactId>test-model</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--BQ deps-->
|
||||
<dependency>
|
||||
<groupId>io.bootique.liquibase</groupId>
|
||||
<artifactId>bootique-liquibase</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.bootique.logback</groupId>
|
||||
<artifactId>bootique-logback</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.bootique.jdbc</groupId>
|
||||
<artifactId>bootique-jdbc-hikaricp-instrumented</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
24
db/src/main/java/test/DbApp.java
Normal file
24
db/src/main/java/test/DbApp.java
Normal file
@ -0,0 +1,24 @@
|
||||
package test;
|
||||
|
||||
import io.bootique.BQCoreModule;
|
||||
import io.bootique.BaseModule;
|
||||
import io.bootique.Bootique;
|
||||
import io.bootique.di.Binder;
|
||||
import io.bootique.meta.application.OptionMetadata;
|
||||
|
||||
public class DbApp extends BaseModule {
|
||||
public static void main(String[] args) {
|
||||
Bootique.main(args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(Binder binder) {
|
||||
BQCoreModule.extend(binder)
|
||||
.addConfig("classpath:test/db/default.yaml")
|
||||
|
||||
// --local
|
||||
.addOption(OptionMetadata.builder("local", "Load configuration for local environment.").build())
|
||||
.mapConfigResource("local", "classpath:test/db/local.yaml")
|
||||
;
|
||||
}
|
||||
}
|
12
db/src/main/java/test/DbAppProvider.java
Normal file
12
db/src/main/java/test/DbAppProvider.java
Normal file
@ -0,0 +1,12 @@
|
||||
package test;
|
||||
|
||||
import io.bootique.BQModuleProvider;
|
||||
|
||||
public class DbAppProvider implements BQModuleProvider {
|
||||
public DbAppProvider() {}
|
||||
|
||||
@Override
|
||||
public DbApp module() {
|
||||
return new DbApp();
|
||||
}
|
||||
}
|
@ -0,0 +1 @@
|
||||
test.DbAppProvider
|
38
db/src/main/resources/init.sql
Normal file
38
db/src/main/resources/init.sql
Normal file
@ -0,0 +1,38 @@
|
||||
-- liquibase formatted sql
|
||||
-- changeset rzen:1
|
||||
|
||||
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
||||
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
||||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `test`.`e1` (
|
||||
`id` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`text` TEXT NULL DEFAULT NULL,
|
||||
`e2_id` INT(5) UNSIGNED NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `fk_e2_idx` (`e2_id` ASC) VISIBLE,
|
||||
CONSTRAINT `fk_e2`
|
||||
FOREIGN KEY (`e2_id`)
|
||||
REFERENCES `test`.`e2` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `test`.`e2` (
|
||||
`id` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`text` TEXT NULL DEFAULT NULL,
|
||||
`e1_id` INT(5) UNSIGNED NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `fk_e1_idx` (`e1_id` ASC) VISIBLE,
|
||||
CONSTRAINT `fk_e1`
|
||||
FOREIGN KEY (`e1_id`)
|
||||
REFERENCES `test`.`e1` (`id`)
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8;
|
||||
|
||||
SET SQL_MODE=@OLD_SQL_MODE;
|
||||
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
||||
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
3
db/src/main/resources/master.yaml
Normal file
3
db/src/main/resources/master.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
databaseChangeLog:
|
||||
- include:
|
||||
file: classpath:init.sql
|
23
db/src/main/resources/test/db/default.yaml
Normal file
23
db/src/main/resources/test/db/default.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
jdbc:
|
||||
test:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
jdbcUrl: "jdbc:mysql://db:3306/test?connectTimeout=0&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8"
|
||||
username: root
|
||||
password: test
|
||||
minimumIdle: 1
|
||||
maximumPoolSize: 20
|
||||
connectionTestQuery: "select 1"
|
||||
autoCommit: false
|
||||
|
||||
# Liquibase Migrations Config
|
||||
liquibase:
|
||||
datasource: test
|
||||
changeLogs:
|
||||
- classpath:master.yaml
|
||||
|
||||
# Logging
|
||||
log:
|
||||
level: info
|
||||
appenders:
|
||||
- type: console
|
||||
logFormat: '[%d{"dd/MMM/yyyy:HH:mm:ss,SSS"}] %t %X %-5p %c{1}: %m%n%ex'
|
3
db/src/main/resources/test/db/local.yaml
Normal file
3
db/src/main/resources/test/db/local.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
jdbc:
|
||||
test:
|
||||
jdbcUrl: "jdbc:mysql://192.168.10.64:33006/test?connectTimeout=0&autoReconnect=true&useUnicode=true&characterEncoding=UTF-8"
|
Reference in New Issue
Block a user