Skip to content

Commit

Permalink
Add flyway dependency for postgresql database support. (#2170)
Browse files Browse the repository at this point in the history
  • Loading branch information
wetted committed Nov 10, 2023
1 parent 08d1377 commit 8afa951
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.micronaut.starter.feature.database.MariaDB;
import io.micronaut.starter.feature.database.MySQL;
import io.micronaut.starter.feature.database.Oracle;
import io.micronaut.starter.feature.database.PostgreSQL;
import io.micronaut.starter.feature.database.SQLServer;
import io.micronaut.starter.feature.oraclecloud.OracleCloudAutonomousDatabase;
import jakarta.inject.Singleton;
Expand All @@ -36,6 +37,7 @@ public class Flyway implements MigrationFeature {
public static final String ARTIFACT_ID_FLYWAY_SQLSERVER = "flyway-sqlserver";
public static final String ARTIFACT_ID_FLYWAY_ORACLE = "flyway-database-oracle";
//https://documentation.red-gate.com/fd/oracle-184127602.html
public static final String ARTIFACT_ID_FLYWAY_POSTGRESQL = "flyway-database-postgresql";
public static final Dependency.Builder DEPENDENCY_FLYWAY_MYSQL = Dependency.builder()
.groupId(GROUP_ID_FLYWAYDB)
.artifactId(ARTIFACT_ID_FLYWAY_MYSQL)
Expand All @@ -45,6 +47,10 @@ public class Flyway implements MigrationFeature {
.groupId(GROUP_ID_FLYWAYDB)
.artifactId(ARTIFACT_ID_FLYWAY_ORACLE)
.runtime();
public static final Dependency.Builder DEPENDENCY_FLYWAY_POSTGRESQL = Dependency.builder()
.groupId(GROUP_ID_FLYWAYDB)
.artifactId(ARTIFACT_ID_FLYWAY_POSTGRESQL)
.runtime();
public static final Dependency.Builder DEPENDENCY_FLYWAY_SQLSERVER = Dependency.builder()
.groupId(GROUP_ID_FLYWAYDB)
.artifactId(ARTIFACT_ID_FLYWAY_SQLSERVER)
Expand Down Expand Up @@ -94,6 +100,9 @@ protected void addDependencies(GeneratorContext generatorContext) {
if (generatorContext.isFeaturePresent(Oracle.class) || generatorContext.isFeaturePresent(OracleCloudAutonomousDatabase.class)) {
generatorContext.addDependency(DEPENDENCY_FLYWAY_ORACLE);
}
if (generatorContext.isFeaturePresent(PostgreSQL.class)) {
generatorContext.addDependency(DEPENDENCY_FLYWAY_POSTGRESQL);
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,16 @@ flyway:
where:
buildTool << BuildTool.values()
}

void "test the flyway-database-postgresql dependency is added to the gradle build when postgres is selected"(BuildTool buildTool) {
when:
BuildTestVerifier verifier = verifier(buildTool, ['flyway', 'postgres'])

then:
verifier.hasDependency("io.micronaut.flyway", "micronaut-flyway", Scope.COMPILE)
verifier.hasDependency("org.flywaydb", "flyway-database-postgresql", Scope.RUNTIME)

where:
buildTool << BuildTool.values()
}
}

0 comments on commit 8afa951

Please sign in to comment.