Flyway
- Custom implementation of Flyway
Usage
-
Add a dependency in your project.
<dependency> <groupId>com.github.bitmc</groupId> <artifactId>flyway-core</artifactId> <version>7.4.0.0</version> </dependency>
-
Implement
SqlReplacer
. You can also use MysqlH2SqlReplacer.package my.project; import org.flywaydb.core.internal.sqlscript.SqlReplacer; public class MySqlReplacer implements SqlReplacer { public String replace(String sql) { ...... } }
-
Setup
CustomFlyway
instance.import org.flywaydb.core.CustomFlyway; import org.flywaydb.core.Flyway; import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; import my.project.MySqlReplacer; Flyway source = Flyway.configure() .locations("classpath:/data/migration") .schemas("example") .sqlMigrationPrefix("") .sqlMigrationSeparator("-") .dataSource(DataSourceBuilder.create().url("jdbc:h2:mem:test;MODE=MySQL;DATABASE_TO_UPPER=FALSE").build()) .load(); CustomFlyway flyway = new CustomFlyway(source, new MySqlReplacer()); flyway.clean(); flyway.migrate();
License
- Apache License 2.0