Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue in Java migration in dev-mode #36371

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ MigrationStateBuildItem build(BuildProducer<NativeImageResourceBuildItem> resour
Location applicationMigrationLocation = new Location(applicationMigration);
String applicationMigrationPath = applicationMigrationLocation.getPath();

if (applicationMigrationPath != null) {
if ((applicationMigrationPath != null) &&
// we don't include .class files in the watched files because that messes up live reload
!applicationMigrationPath.endsWith(".class")) {
hotDeploymentProducer.produce(new HotDeploymentWatchedFileBuildItem(applicationMigrationPath));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.quarkus.flyway.test;

import static io.restassured.RestAssured.get;
import static org.hamcrest.Matchers.is;

import java.sql.SQLException;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import db.migration.V1_0_1__Update;
import db.migration.V1_0_2__Update;
import io.quarkus.test.QuarkusDevModeTest;

public class FlywayExtensionWithJavaMigrationDevModeTest {

@RegisterExtension
static final QuarkusDevModeTest config = new QuarkusDevModeTest()
.withApplicationRoot((jar) -> jar
.addClasses(V1_0_1__Update.class, V1_0_2__Update.class,
FlywayExtensionWithJavaMigrationDevModeTestEndpoint.class)
.addAsResource("db/migration/V1.0.0__Quarkus.sql")
.addAsResource("clean-and-migrate-at-start-config.properties", "application.properties"));

@Test
public void test() throws SQLException {
get("/fly")
.then()
.statusCode(200)
.body(is("2/1.0.2"));

config.modifySourceFile(FlywayExtensionWithJavaMigrationDevModeTestEndpoint.class, s -> s.replace("/fly", "/flyway"));

get("/flyway")
.then()
.statusCode(200)
.body(is("2/1.0.2"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.quarkus.flyway.test;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

import org.flywaydb.core.Flyway;

import io.agroal.api.AgroalDataSource;

@Path("/fly")
public class FlywayExtensionWithJavaMigrationDevModeTestEndpoint {

@Inject
AgroalDataSource defaultDataSource;

@Inject
Flyway flyway;

@GET
public String result() throws Exception {
int count = 0;
try (Connection connection = defaultDataSource.getConnection(); Statement stat = connection.createStatement()) {
try (ResultSet countQuery = stat.executeQuery("select count(1) from quarked_flyway")) {
countQuery.first();
count = countQuery.getInt(1);
}
}
String currentVersion = flyway.info().current().getVersion().toString();

return count + "/" + currentVersion;
}
}
Loading