Skip to content

Commit

Permalink
Provide API in MigrationRunner to run Migration with individual context
Browse files Browse the repository at this point in the history
  • Loading branch information
rPraml committed Dec 11, 2023
1 parent 22db0d9 commit 769b0c1
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public List<MigrationResource> checkState(Connection connection) {
return run(connection, true);
}

/**
* Return the migrations that would be applied if the migration is run.
*/
public List<MigrationResource> checkState(MigrationContext context) {
return run(context, true);
}

/**
* Run by creating a DB connection from driver, url, username defined in MigrationConfig.
*/
Expand All @@ -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 {
Expand All @@ -86,4 +100,10 @@ private List<MigrationResource> run(Connection connection, boolean checkStateOnl
return new MigrationEngine(migrationConfig, checkStateOnly).run(connection);
}

/**
* Run the migrations if there are any that need running.
*/
private List<MigrationResource> run(MigrationContext context, boolean checkStateOnly) {
return new MigrationEngine(migrationConfig, checkStateOnly).run(context);
}
}

0 comments on commit 769b0c1

Please sign in to comment.