From 769b0c108618a51331270d95f5bf6a5f460b3322 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Mon, 11 Dec 2023 14:29:48 +0100 Subject: [PATCH] Provide API in MigrationRunner to run Migration with individual context --- .../io/ebean/migration/MigrationRunner.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java b/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java index 165febf..b3270f7 100644 --- a/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java +++ b/ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java @@ -44,6 +44,13 @@ public List checkState(Connection connection) { return run(connection, true); } + /** + * Return the migrations that would be applied if the migration is run. + */ + public List checkState(MigrationContext context) { + return run(context, true); + } + /** * Run by creating a DB connection from driver, url, username defined in MigrationConfig. */ @@ -65,6 +72,13 @@ public void run(Connection connection) { run(connection, false); } + /** + * Run the migrations if there are any that need running. + */ + public void run(MigrationContext context) { + run(context, false); + } + private Connection connection(DataSource dataSource) { String username = migrationConfig.getDbUsername(); try { @@ -86,4 +100,10 @@ private List run(Connection connection, boolean checkStateOnl return new MigrationEngine(migrationConfig, checkStateOnly).run(connection); } + /** + * Run the migrations if there are any that need running. + */ + private List run(MigrationContext context, boolean checkStateOnly) { + return new MigrationEngine(migrationConfig, checkStateOnly).run(context); + } }