From 5564bf9b4f5eebf1667c81d331aa82db8bab41f7 Mon Sep 17 00:00:00 2001 From: ViacheslavKlimov Date: Fri, 5 Jul 2024 14:02:27 +0300 Subject: [PATCH 1/2] Upgrade script from 3.7.0 to 3.7.1 --- .../main/data/upgrade/3.7.0/schema_update.sql | 16 ++++++++++++++++ .../install/ThingsboardInstallService.java | 4 ++++ .../install/SqlDatabaseUpgradeService.java | 4 ++++ 3 files changed, 24 insertions(+) create mode 100644 application/src/main/data/upgrade/3.7.0/schema_update.sql diff --git a/application/src/main/data/upgrade/3.7.0/schema_update.sql b/application/src/main/data/upgrade/3.7.0/schema_update.sql new file mode 100644 index 0000000000..6b87dc6dde --- /dev/null +++ b/application/src/main/data/upgrade/3.7.0/schema_update.sql @@ -0,0 +1,16 @@ +-- +-- Copyright © 2016-2024 The Thingsboard Authors +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- + diff --git a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java index 4bef0d420a..85eb64ffba 100644 --- a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java +++ b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java @@ -137,6 +137,10 @@ public void performInstall() { entityDatabaseSchemaService.createCustomerTitleUniqueConstraintIfNotExists(); systemDataLoaderService.updateDefaultNotificationConfigs(false); systemDataLoaderService.updateSecuritySettings(); + break; + case "3.7.0": + log.info("Upgrading ThingsBoard from version 3.7.0 to 3.7.1 ..."); + databaseEntitiesUpgradeService.upgradeDatabase("3.7.0"); //TODO DON'T FORGET to update switch statement in the CacheCleanupService if you need to clear the cache break; default: diff --git a/application/src/main/java/org/thingsboard/server/service/install/SqlDatabaseUpgradeService.java b/application/src/main/java/org/thingsboard/server/service/install/SqlDatabaseUpgradeService.java index 86d922c305..2d5ac5a99b 100644 --- a/application/src/main/java/org/thingsboard/server/service/install/SqlDatabaseUpgradeService.java +++ b/application/src/main/java/org/thingsboard/server/service/install/SqlDatabaseUpgradeService.java @@ -121,6 +121,9 @@ public void upgradeDatabase(String fromVersion) throws Exception { case "3.6.4": updateSchema("3.6.4", 3006004, "3.7.0", 3007000, null); break; + case "3.7.0": + updateSchema("3.7.0", 3007000, "3.7.1", 3007001, null); + break; default: throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion); } @@ -189,4 +192,5 @@ protected boolean isOldSchema(Connection conn, long fromVersion) { } return isOldSchema; } + } From 49c3c31b405d6a2a84b9bb9c668533ca442449df Mon Sep 17 00:00:00 2001 From: ViacheslavKlimov Date: Fri, 5 Jul 2024 14:05:39 +0300 Subject: [PATCH 2/2] Remove invalid break from upgrade service --- .../thingsboard/server/install/ThingsboardInstallService.java | 1 - 1 file changed, 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java index 85eb64ffba..75ac97881c 100644 --- a/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java +++ b/application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java @@ -137,7 +137,6 @@ public void performInstall() { entityDatabaseSchemaService.createCustomerTitleUniqueConstraintIfNotExists(); systemDataLoaderService.updateDefaultNotificationConfigs(false); systemDataLoaderService.updateSecuritySettings(); - break; case "3.7.0": log.info("Upgrading ThingsBoard from version 3.7.0 to 3.7.1 ..."); databaseEntitiesUpgradeService.upgradeDatabase("3.7.0");