-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMigrationRunnerDb.java
More file actions
44 lines (38 loc) · 1.12 KB
/
MigrationRunnerDb.java
File metadata and controls
44 lines (38 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package io.ebean.migration.db;
import io.ebean.Database;
import io.ebean.Transaction;
import io.ebean.migration.MigrationConfig;
import io.ebean.migration.MigrationResource;
import io.ebean.migration.MigrationRunner;
import java.util.List;
/**
* Runs the default checkState and run method on a current ebean server.
*
* @author Roland Praml, FOCONIS AG
*/
public class MigrationRunnerDb extends MigrationRunner {
private final Database db;
public MigrationRunnerDb(MigrationConfig migrationConfig, Database db) {
super(migrationConfig);
this.db = db;
}
/**
* Return the migrations that would be applied if the migration is run.
*/
@Override
public List<MigrationResource> checkState() {
try (Transaction txn = db.beginTransaction()) {
return checkState(new TransactionBasedMigrationContext(migrationConfig, txn, db));
}
}
/**
* Run the migrations if there are any that need running.
*/
@Override
public void run() {
try (Transaction txn = db.beginTransaction()) {
run(new TransactionBasedMigrationContext(migrationConfig, txn, db));
// No commit here!
}
}
}