forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly support subfolders for Flyway database migrations
Fix quarkusio#11288
- Loading branch information
Showing
4 changed files
with
80 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...ment/src/test/java/io/quarkus/flyway/test/FlywayExtensionMigrateAtStartSubfolderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.quarkus.flyway.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.flywaydb.core.Flyway; | ||
import org.flywaydb.core.api.MigrationInfo; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class FlywayExtensionMigrateAtStartSubfolderTest { | ||
// Quarkus built object | ||
@Inject | ||
Flyway flyway; | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addAsResource("db/migration-subfolder/subfolder/V1.0.0__Quarkus.sql") | ||
.addAsResource("migrate-at-start-subfolder-config.properties", "application.properties")); | ||
|
||
@Test | ||
@DisplayName("Migrates at start correctly") | ||
public void testFlywayConfigInjection() { | ||
MigrationInfo migrationInfo = flyway.info().current(); | ||
assertNotNull(migrationInfo, "No Flyway migration was executed"); | ||
|
||
String currentVersion = migrationInfo | ||
.getVersion() | ||
.toString(); | ||
// Expected to be 1.0.0 as migration runs at start | ||
assertEquals("1.0.0", currentVersion); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...flyway/deployment/src/test/resources/db/migration-subfolder/subfolder/V1.0.0__Quarkus.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE TABLE quarked_flyway | ||
( | ||
id INT, | ||
name VARCHAR(20) | ||
); |
8 changes: 8 additions & 0 deletions
8
extensions/flyway/deployment/src/test/resources/migrate-at-start-subfolder-config.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
quarkus.datasource.db-kind=h2 | ||
quarkus.datasource.username=sa | ||
quarkus.datasource.password=sa | ||
quarkus.datasource.jdbc.url=jdbc:h2:tcp://localhost/mem:test-quarkus-migrate-at-start-subfolder;DB_CLOSE_DELAY=-1 | ||
|
||
# Flyway config properties | ||
quarkus.flyway.locations=db/migration-subfolder | ||
quarkus.flyway.migrate-at-start=true |