Commit 722727e0847ba5ccbbcadc0a93f377908c112fa8

Authored by Igor Kulikov
1 parent 2251dae9

Add Sql upgrade script

  1 +--
  2 +-- Copyright © 2016-2019 The Thingsboard Authors
  3 +--
  4 +-- Licensed under the Apache License, Version 2.0 (the "License");
  5 +-- you may not use this file except in compliance with the License.
  6 +-- You may obtain a copy of the License at
  7 +--
  8 +-- http://www.apache.org/licenses/LICENSE-2.0
  9 +--
  10 +-- Unless required by applicable law or agreed to in writing, software
  11 +-- distributed under the License is distributed on an "AS IS" BASIS,
  12 +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +-- See the License for the specific language governing permissions and
  14 +-- limitations under the License.
  15 +--
  16 +
  17 +ALTER TABLE event ALTER COLUMN body SET DATA TYPE varchar(10000000);
@@ -106,8 +106,10 @@ public class ThingsboardInstallService { @@ -106,8 +106,10 @@ public class ThingsboardInstallService {
106 106
107 databaseUpgradeService.upgradeDatabase("2.1.3"); 107 databaseUpgradeService.upgradeDatabase("2.1.3");
108 108
109 - case "2.2.0":  
110 - log.info("Upgrading ThingsBoard from version 2.2.0 to 2.3.0 ..."); 109 + case "2.3.0":
  110 + log.info("Upgrading ThingsBoard from version 2.3.0 to 2.3.1 ...");
  111 +
  112 + databaseUpgradeService.upgradeDatabase("2.3.0");
111 113
112 log.info("Updating system data..."); 114 log.info("Updating system data...");
113 115
@@ -253,6 +253,8 @@ public class CassandraDatabaseUpgradeService implements DatabaseUpgradeService { @@ -253,6 +253,8 @@ public class CassandraDatabaseUpgradeService implements DatabaseUpgradeService {
253 break; 253 break;
254 case "2.1.3": 254 case "2.1.3":
255 break; 255 break;
  256 + case "2.3.0":
  257 + break;
256 default: 258 default:
257 throw new RuntimeException("Unable to upgrade Cassandra database, unsupported fromVersion: " + fromVersion); 259 throw new RuntimeException("Unable to upgrade Cassandra database, unsupported fromVersion: " + fromVersion);
258 } 260 }
@@ -157,6 +157,14 @@ public class SqlDatabaseUpgradeService implements DatabaseUpgradeService { @@ -157,6 +157,14 @@ public class SqlDatabaseUpgradeService implements DatabaseUpgradeService {
157 log.info("Schema updated."); 157 log.info("Schema updated.");
158 } 158 }
159 break; 159 break;
  160 + case "2.3.0":
  161 + try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
  162 + log.info("Updating schema ...");
  163 + schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "2.3.1", SCHEMA_UPDATE_SQL);
  164 + loadSql(schemaUpdateFile, conn);
  165 + log.info("Schema updated.");
  166 + }
  167 + break;
160 default: 168 default:
161 throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion); 169 throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
162 } 170 }
@@ -40,7 +40,7 @@ @@ -40,7 +40,7 @@
40 <tb-cassandra.docker.name>tb-cassandra</tb-cassandra.docker.name> 40 <tb-cassandra.docker.name>tb-cassandra</tb-cassandra.docker.name>
41 <pkg.user>thingsboard</pkg.user> 41 <pkg.user>thingsboard</pkg.user>
42 <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder> 42 <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder>
43 - <pkg.upgradeVersion>2.2.0</pkg.upgradeVersion> 43 + <pkg.upgradeVersion>2.3.0</pkg.upgradeVersion>
44 </properties> 44 </properties>
45 45
46 <dependencies> 46 <dependencies>