[BAEL4288] initial commit
This commit is contained in:
parent
6ebf84fcb8
commit
be1f906a9a
3
persistence-modules/flyway-repair/README.MD
Normal file
3
persistence-modules/flyway-repair/README.MD
Normal file
@ -0,0 +1,3 @@
|
||||
### Relevant Articles:
|
||||
- [Database Migrations with Flyway](http://www.baeldung.com/database-migrations-with-flyway)
|
||||
- [A Guide to Flyway Callbacks](http://www.baeldung.com/flyway-callbacks)
|
2
persistence-modules/flyway-repair/docker-compose/.env
Normal file
2
persistence-modules/flyway-repair/docker-compose/.env
Normal file
@ -0,0 +1,2 @@
|
||||
MYSQL_PORT=3316
|
||||
POSTGRES_PORT=5431
|
@ -0,0 +1,23 @@
|
||||
version: '3.0'
|
||||
|
||||
services:
|
||||
mysql-test:
|
||||
image: mysql:8.0.17
|
||||
ports:
|
||||
- ${MYSQL_PORT}:3306
|
||||
env_file:
|
||||
- mysql.env
|
||||
networks:
|
||||
- baeldung
|
||||
|
||||
postgres-test:
|
||||
image: postgres:11.5
|
||||
ports:
|
||||
- ${POSTGRES_PORT}:5432
|
||||
env_file: postgres.env
|
||||
networks:
|
||||
- baeldung
|
||||
|
||||
networks:
|
||||
baeldung:
|
||||
driver: bridge
|
@ -0,0 +1,5 @@
|
||||
MYSQL_ROOT_PASSWORD=password
|
||||
MYSQL_RANDOM_ROOT_PASSWORD=yes
|
||||
MYSQL_USER=testuser
|
||||
MYSQL_PASSWORD=password
|
||||
MYSQL_DATABASE=testdb
|
@ -0,0 +1,3 @@
|
||||
POSTGRES_USER=testuser
|
||||
POSTGRES_PASSWORD=password
|
||||
POSTGRES_DB=testdb
|
105
persistence-modules/flyway-repair/pom.xml
Normal file
105
persistence-modules/flyway-repair/pom.xml
Normal file
@ -0,0 +1,105 @@
|
||||
<?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>
|
||||
<artifactId>flyway</artifactId>
|
||||
<name>flyway-repair</name>
|
||||
<packaging>jar</packaging>
|
||||
<description>Flyway Repair Demo</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-core</artifactId>
|
||||
<version>${flyway-core.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-maven-plugin</artifactId>
|
||||
<version>${flyway-maven-plugin.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>*.properties</include>
|
||||
<include>db/**/*.sql</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<flyway-core.version>6.5.0</flyway-core.version>
|
||||
<flyway-maven-plugin.version>6.5.0</flyway-maven-plugin.version>
|
||||
<flyway.configFiles>src/main/resources/application-${db.engine}.properties</flyway.configFiles>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
|
||||
<profile>
|
||||
<id>h2</id>
|
||||
<properties>
|
||||
<db.engine>h2</db.engine>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>mysql</id>
|
||||
<properties>
|
||||
<db.engine>mysql</db.engine>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>postgres</id>
|
||||
<properties>
|
||||
<db.engine>postgres</db.engine>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
|
||||
</project>
|
@ -0,0 +1,13 @@
|
||||
package com.baeldung.flywaycallbacks;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class FlywayApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(FlywayApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
flyway.locations=db/migration,db/callbacks
|
@ -0,0 +1,3 @@
|
||||
flyway.url=jdbc:h2:file:./testdb;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE;MODE=MySQL;DATABASE_TO_UPPER=false;
|
||||
flyway.user=testuser
|
||||
flyway.password=password
|
@ -0,0 +1,3 @@
|
||||
flyway.url=jdbc:mysql://127.0.0.1:3316/testdb
|
||||
flyway.user=testuser
|
||||
flyway.password=password
|
@ -0,0 +1,3 @@
|
||||
flyway.url=jdbc:postgresql://127.0.0.1:5431/testdb
|
||||
flyway.user=testuser
|
||||
flyway.password=password
|
@ -0,0 +1,6 @@
|
||||
spring.profiles.include=@db.engine@
|
||||
|
||||
spring.datasource.url=${flyway.url}
|
||||
spring.datasource.username=${flyway.user}
|
||||
spring.datasource.password=${flyway.password}
|
||||
spring.flyway.locations=${flyway.locations:db/migration}
|
@ -0,0 +1 @@
|
||||
DELETE FROM flyway_schema_history WHERE success=false;
|
@ -0,0 +1,3 @@
|
||||
create table table_one (
|
||||
id numeric primary key
|
||||
);
|
@ -0,0 +1,3 @@
|
||||
create table table_two (
|
||||
id numeric primary key
|
||||
);
|
@ -0,0 +1,3 @@
|
||||
create table table_three (
|
||||
id numeric primary key
|
||||
);
|
@ -0,0 +1,3 @@
|
||||
create table table_one (
|
||||
id numeric primary key
|
||||
);
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="org.springframework" level="WARN" />
|
||||
<logger name="org.springframework.transaction" level="WARN" />
|
||||
|
||||
<!-- in order to debug some marshalling issues, this needs to be TRACE -->
|
||||
<logger name="org.springframework.web.servlet.mvc" level="WARN" />
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
Loading…
x
Reference in New Issue
Block a user