Flyway Plus
- Custom implementation for Flyway
- Note: This project is unofficial and experimental.
Products
CustomFlyway extends Flyway
- Additional method: setPlaceholderReplacer(PlaceholderReplacer)
MysqlH2SqlReplacer implements PlaceholderReplacer
- Replace MySQL-SQL to H2-SQL on migration
Usage
-
Add a dependency in your project.
<dependency> <groupId>com.github.spt-oss</groupId> <artifactId>flyway-core</artifactId> <version>5.2.4.0</version> </dependency>
-
Create a subclass of
PlaceholderReplacer
. You can also useMysqlH2SqlReplacer
.package my.project; import org.flywaydb.core.internal.util.placeholder.PlaceholderReplacer; public class MyPlaceholderReplacer implements PlaceholderReplacer { ...... }
-
Setup
CustomFlyway
instance.import java.sql.DataSource; import org.flywaydb.core.CustomFlyway; import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; import my.project.MyPlaceholderReplacer; DataSource dataSource = DataSourceBuilder.create().url("jdbc:mysql://host:3306/db").build(); CustomFlyway flyway = new CustomFlyway(); flyway.setLocations("classpath:/data"); flyway.setSchemas("foo", "bar"); flyway.setDataSource(dataSource); flyway.setPlaceholderReplacer(new MyPlaceholderReplacer()); flyway.migrate();
License
- This software is released under the Apache License 2.0.