Skip to content

Instantly share code, notes, and snippets.

@ethan-gallant
Created October 1, 2021 17:54
Show Gist options
  • Save ethan-gallant/449d96bfec012076ab4a34f86435bbde to your computer and use it in GitHub Desktop.
Save ethan-gallant/449d96bfec012076ab4a34f86435bbde to your computer and use it in GitHub Desktop.
Quarkus Flyway Workaround
package net.rocketplatform.service.player.database;
import io.quarkus.runtime.StartupEvent;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.flywaydb.core.Flyway;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
@ApplicationScoped
public class MigrationHandler {
@ConfigProperty(name = "quarkus.flyway.migrate-at-start")
boolean runMigration;
@ConfigProperty(name = "quarkus.datasource.reactive.url")
String datasourceUrl;
@ConfigProperty(name = "quarkus.datasource.username")
String datasourceUsername;
@ConfigProperty(name = "quarkus.datasource.password")
String datasourcePassword;
public void runFlywayMigration(@Observes StartupEvent event) {
if (runMigration) {
Flyway flyway = Flyway.configure().dataSource( "jdbc:" +datasourceUrl.replace("vertx-reactive:", ""), datasourceUsername, datasourcePassword).load();
flyway.migrate();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment