Skip to content

Commit 85586bb

Browse files
committed
Add an INFO level log message when non-transactional migrations are run
1 parent 8518b23 commit 85586bb

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected void run(Connection connection, boolean checkStateOnly) {
9393
return;
9494
}
9595

96-
long start = System.currentTimeMillis();
96+
long startMs = System.currentTimeMillis();
9797
connection.setAutoCommit(false);
9898
MigrationPlatform platform = derivePlatformName(migrationConfig, connection);
9999
new MigrationSchema(migrationConfig, connection).createAndSetIfNeeded();
@@ -105,9 +105,12 @@ protected void run(Connection connection, boolean checkStateOnly) {
105105
runMigrations(migrations, table, checkStateOnly);
106106
connection.commit();
107107
if (!checkStateOnly) {
108-
long exeMillis = System.currentTimeMillis() - start;
109-
log.log(INFO, "DB migrations completed in {0}ms - executed:{1} size:{2}", exeMillis, table.count(), migrations.size());
110-
table.runNonTransactional();
108+
long commitMs = System.currentTimeMillis();
109+
log.log(INFO, "DB migrations completed in {0}ms - executed:{1} totalMigrations:{2}", (commitMs - startMs), table.count(), migrations.size());
110+
int countNonTransactional = table.runNonTransactional();
111+
if (countNonTransactional > 0) {
112+
log.log(INFO, "Non-transactional DB migrations completed in {0}ms - executed:{1}", (System.currentTimeMillis() - commitMs), countNonTransactional);
113+
}
111114
}
112115
} finally {
113116
table.unlockMigrationTable();

ebean-migration/src/main/java/io/ebean/migration/runner/MigrationScriptRunner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ void runScript(String content, String scriptName) throws SQLException {
3434
nonTransactional.addAll(runner.runAll(content, connection));
3535
}
3636

37-
public void runNonTransactional() {
37+
int runNonTransactional() {
3838
if (!nonTransactional.isEmpty()) {
3939
DdlRunner runner = new DdlRunner(false, "Non-transactional DDL", platform.ddlDetect());
4040
runner.runNonTransactional(connection, nonTransactional);
4141
}
42+
return nonTransactional.size();
4243
}
4344
}

ebean-migration/src/main/java/io/ebean/migration/runner/MigrationTable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ private void runRepeatableInit(List<LocalMigrationResource> localVersions) throw
554554
* as such the migration isn't truely atomic - the migration can run and
555555
* complete and the non-transactional statements fail.
556556
*/
557-
public void runNonTransactional() {
558-
scriptRunner.runNonTransactional();
557+
public int runNonTransactional() {
558+
return scriptRunner.runNonTransactional();
559559
}
560560

561561
public int count() {

0 commit comments

Comments
 (0)