#2577 - Refactor internals remove no longer needed DdlAutoCommit platform option

This commit is contained in:
Rob Bygrave committed 2022-03-01 22:32:09 +13:00
1 parent e8df81d78a
commit ffad9abeef
3 files changed
+2 -20

No files matched your search

@@ -606,13 +606,6 @@ public class DatabasePlatform {
this.useMigrationStoredProcedures = useMigrationStoredProcedures; this.useMigrationStoredProcedures = useMigrationStoredProcedures;
} }
/**
* Normally not needed - overridden in CockroachPlatform.
*/
public boolean isDdlAutoCommit() {
return false;
}
/** /**
* Return the DB identity/sequence features for this platform. * Return the DB identity/sequence features for this platform.
* *
@@ -14,12 +14,4 @@ public class CockroachPlatform extends PostgresPlatform {
this.historySupport = null; // not yet implemented in DDL this.historySupport = null; // not yet implemented in DDL
} }
/**
* Needs a commit after create index such that alter table add foreign key ... succeeds.
*/
@Override
public boolean isDdlAutoCommit() {
return false;
}
} }
@@ -44,7 +44,6 @@ public class DdlGenerator implements SpiDdlGenerator {
private final boolean extraDdl; private final boolean extraDdl;
private final boolean createOnly; private final boolean createOnly;
private final boolean jaxbPresent; private final boolean jaxbPresent;
private final boolean ddlAutoCommit;
private final String dbSchema; private final String dbSchema;
private final ScriptTransform scriptTransform; private final ScriptTransform scriptTransform;
private final Platform platform; private final Platform platform;
@@ -70,11 +69,9 @@ public class DdlGenerator implements SpiDdlGenerator {
if (!config.getTenantMode().isDdlEnabled() && config.isDdlRun()) { if (!config.getTenantMode().isDdlEnabled() && config.isDdlRun()) {
log.warn("DDL can't be run on startup with TenantMode " + config.getTenantMode()); log.warn("DDL can't be run on startup with TenantMode " + config.getTenantMode());
this.runDdl = false; this.runDdl = false;
this.ddlAutoCommit = false;
this.useMigrationStoredProcedures = false; this.useMigrationStoredProcedures = false;
} else { } else {
this.runDdl = config.isDdlRun(); this.runDdl = config.isDdlRun();
this.ddlAutoCommit = databasePlatform.isDdlAutoCommit();
this.useMigrationStoredProcedures = config.getDatabasePlatform().isUseMigrationStoredProcedures(); this.useMigrationStoredProcedures = config.getDatabasePlatform().isUseMigrationStoredProcedures();
} }
this.scriptTransform = createScriptTransform(config); this.scriptTransform = createScriptTransform(config);
@@ -166,11 +163,11 @@ public class DdlGenerator implements SpiDdlGenerator {
DdlRunner runner = createDdlRunner(expectErrors, scriptName); DdlRunner runner = createDdlRunner(expectErrors, scriptName);
try { try {
if (expectErrors || ddlAutoCommit) { if (expectErrors) {
connection.setAutoCommit(true); connection.setAutoCommit(true);
} }
runner.runAll(scriptTransform.transform(content), connection); runner.runAll(scriptTransform.transform(content), connection);
if (expectErrors || ddlAutoCommit) { if (expectErrors) {
connection.setAutoCommit(false); connection.setAutoCommit(false);
} }
connection.commit(); connection.commit();