[jOOQ/jOOQ#9506] Insert CHANGELOG record prior to migration

- Insert the record already before migrating, then update
- Added more TODOs
This commit is contained in:
Lukas Eder 2019-11-21 19:40:51 +01:00
parent 83da9e2c23
commit a306211890

View File

@ -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;
}