From a306211890ec5d5bd999911306e1ccbeb6caffa1 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Thu, 21 Nov 2019 19:40:51 +0100 Subject: [PATCH] [jOOQ/jOOQ#9506] Insert CHANGELOG record prior to migration - Insert the record already before migrating, then update - Added more TODOs --- .../java/org/jooq/impl/MigrationImpl.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/MigrationImpl.java b/jOOQ/src/main/java/org/jooq/impl/MigrationImpl.java index f88691fea2..723e9352ee 100644 --- a/jOOQ/src/main/java/org/jooq/impl/MigrationImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/MigrationImpl.java @@ -137,6 +137,14 @@ final class MigrationImpl extends AbstractScope implements Migration { return MIGRATION_RESULT; } + // TODO: Implement preconditions + // TODO: Implement a listener with a variety of pro / oss features + // TODO: Implement additional out-of-the-box sanity checks + // TODO: Allow undo migrations only if enabled explicitly + // TODO: Add number of statements to CHANGELOG + // TODO: Add option to log the entire changeset in CHANGELOG + // TODO: Add a migration state to the CHANGELOG: SUCCESS, PENDING, FAILURE + log.info("jOOQ Migrations", "Version " + from().id() + " is migrated to " + to().id()); StopWatch watch = new StopWatch(); @@ -146,17 +154,22 @@ final class MigrationImpl extends AbstractScope implements Migration { for (Query query : queries()) log.debug("jOOQ Migrations", dsl().renderInlined(query)); - // TODO: Make batching an option - queries().executeBatch(); - JooqMigrationsChangelogRecord newRecord = dsl().newRecord(CHANGELOG); + newRecord .setJooqVersion(Constants.VERSION) .setMigratedAt(new Timestamp(System.currentTimeMillis())) .setMigratedFrom(from().id()) .setMigratedTo(to().id()) + .setMigrationTime(0L) + .insert(); + + // TODO: Make batching an option + queries().executeBatch(); + + newRecord .setMigrationTime(watch.split() / 1000000L) - .store(); + .update(); return MIGRATION_RESULT; }