Skip to content

Commit 769b0c1

Browse files
committed
Provide API in MigrationRunner to run Migration with individual context
1 parent 22db0d9 commit 769b0c1

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public List<MigrationResource> checkState(Connection connection) {
4444
return run(connection, true);
4545
}
4646

47+
/**
48+
* Return the migrations that would be applied if the migration is run.
49+
*/
50+
public List<MigrationResource> checkState(MigrationContext context) {
51+
return run(context, true);
52+
}
53+
4754
/**
4855
* Run by creating a DB connection from driver, url, username defined in MigrationConfig.
4956
*/
@@ -65,6 +72,13 @@ public void run(Connection connection) {
6572
run(connection, false);
6673
}
6774

75+
/**
76+
* Run the migrations if there are any that need running.
77+
*/
78+
public void run(MigrationContext context) {
79+
run(context, false);
80+
}
81+
6882
private Connection connection(DataSource dataSource) {
6983
String username = migrationConfig.getDbUsername();
7084
try {
@@ -86,4 +100,10 @@ private List<MigrationResource> run(Connection connection, boolean checkStateOnl
86100
return new MigrationEngine(migrationConfig, checkStateOnly).run(connection);
87101
}
88102

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

0 commit comments

Comments
 (0)