diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/AbstractSymmetricEngine.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/AbstractSymmetricEngine.java index 2702ed5813..aa7d1bf58c 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/AbstractSymmetricEngine.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/AbstractSymmetricEngine.java @@ -509,10 +509,24 @@ public void setup() { public void setupDatabase(boolean force) { log.info("Initializing SymmetricDS database"); - if (parameterService.is(ParameterConstants.AUTO_CONFIGURE_DATABASE) || force) { - symmetricDialect.initTablesAndDatabaseObjects(); + boolean isAutoConfigDatabase = parameterService.is(ParameterConstants.AUTO_CONFIGURE_DATABASE); + boolean isAutoConfigDatabaseFast = parameterService.is(ParameterConstants.AUTO_CONFIGURE_DATABASE_FAST); + + if (force || isAutoConfigDatabase) { + if (isAutoConfigDatabaseFast && !hasSoftwareVersionChanged()) { + log.info("Version matches for tables and objects"); + } else { + log.info("Checking tables and objects"); + symmetricDialect.initTablesAndDatabaseObjects(); + } } else { - log.info("SymmetricDS is not configured to auto-create the database"); + if (hasSoftwareVersionChanged()) { + throw new SymmetricException("Upgrade of SymmetricDS runtime tables to version " + Version.version() + + " is required. Enable " + ParameterConstants.AUTO_CONFIGURE_DATABASE + + " parameter for automatic upgrade of tables or perform manual upgrade with symadmin."); + } else { + log.info("SymmetricDS is not configured to auto-create the database"); + } } try { configurationService.initDefaultChannels(); @@ -531,6 +545,14 @@ public void setupDatabase(boolean force) { log.info("Done initializing SymmetricDS database"); } + protected boolean hasSoftwareVersionChanged() { + Node identity = nodeService.findIdentity(); + if (identity != null) { + return !Version.version().equals(identity.getSymmetricVersion()); + } + return true; + } + protected void autoConfigRegistrationServer() { Node node = nodeService.findIdentity(); diff --git a/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java b/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java index 8a67151d85..cd1378060d 100644 --- a/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java +++ b/symmetric-core/src/main/java/org/jumpmind/symmetric/common/ParameterConstants.java @@ -138,6 +138,7 @@ private ParameterConstants() { public final static String AUTO_SYNC_CONFIGURATION = "auto.sync.configuration"; public final static String AUTO_SYNC_CONFIGURATION_ON_INCOMING = "auto.sync.configuration.on.incoming"; public final static String AUTO_CONFIGURE_DATABASE = "auto.config.database"; + public final static String AUTO_CONFIGURE_DATABASE_FAST = "auto.config.database.fast"; public final static String AUTO_SYNC_TRIGGERS = "auto.sync.triggers"; public final static String AUTO_SYNC_TRIGGERS_AT_STARTUP = "auto.sync.triggers.at.startup"; public final static String AUTO_SYNC_CONFIG_AT_STARTUP = "auto.sync.config.at.startup"; diff --git a/symmetric-core/src/main/resources/symmetric-default.properties b/symmetric-core/src/main/resources/symmetric-default.properties index 0ee3792fe5..b2924db022 100644 --- a/symmetric-core/src/main/resources/symmetric-default.properties +++ b/symmetric-core/src/main/resources/symmetric-default.properties @@ -617,6 +617,13 @@ auto.start.engine=true # Type: boolean auto.config.database=true +# If both auto.config.database and this parameter are true when symmetric starts up, it will only try to create the necessary tables +# if the current software version is different from the version used during the last start up (stored on sym_node.symmetric_version). +# +# Tags: general +# Type: boolean +auto.config.database.fast=true + # If this is true, triggers will be created or dropped to match configuration during the sync triggers process. # # DatabaseOverridable: true