Browse Source

Fix for entity view keys sql field

pull/1240/head
Volodymyr Babak 8 years ago
parent
commit
7c381995fb
  1. 17
      application/src/main/data/upgrade/2.2.1/schema_update.sql
  2. 6
      application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java
  3. 8
      application/src/main/java/org/thingsboard/server/service/install/SqlDatabaseUpgradeService.java
  4. 8
      dao/src/main/java/org/thingsboard/server/dao/model/nosql/EntityViewEntity.java
  5. 2
      dao/src/main/resources/sql/schema-entities.sql

17
application/src/main/data/upgrade/2.2.1/schema_update.sql

@ -0,0 +1,17 @@
--
-- Copyright © 2016-2018 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.
--
ALTER TABLE entity_view ALTER COLUMN keys SET DATA TYPE varchar(10000000);

6
application/src/main/java/org/thingsboard/server/install/ThingsboardInstallService.java

@ -101,11 +101,17 @@ public class ThingsboardInstallService {
log.info("Upgrading ThingsBoard from version 2.1.1 to 2.1.2 ...");
databaseUpgradeService.upgradeDatabase("2.1.1");
case "2.1.3":
log.info("Upgrading ThingsBoard from version 2.1.3 to 2.2.0 ...");
databaseUpgradeService.upgradeDatabase("2.1.3");
case "2.2.0":
log.info("Upgrading ThingsBoard from version 2.2.0 to 2.2.1 ...");
databaseUpgradeService.upgradeDatabase("2.2.0");
log.info("Updating system data...");
systemDataLoaderService.deleteSystemWidgetBundle("charts");

8
application/src/main/java/org/thingsboard/server/service/install/SqlDatabaseUpgradeService.java

@ -157,6 +157,14 @@ public class SqlDatabaseUpgradeService implements DatabaseUpgradeService {
log.info("Schema updated.");
}
break;
case "2.2.0":
try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
log.info("Updating schema ...");
schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "2.2.1", SCHEMA_UPDATE_SQL);
loadSql(schemaUpdateFile, conn);
log.info("Schema updated.");
}
break;
default:
throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
}

8
dao/src/main/java/org/thingsboard/server/dao/model/nosql/EntityViewEntity.java

@ -60,10 +60,6 @@ public class EntityViewEntity implements SearchTextEntity<EntityView> {
@Column(name = ID_PROPERTY)
private UUID id;
@Enumerated(EnumType.STRING)
@Column(name = ENTITY_TYPE_PROPERTY)
private EntityType entityType;
@PartitionKey(value = 1)
@Column(name = ModelConstants.ENTITY_VIEW_TENANT_ID_PROPERTY)
private UUID tenantId;
@ -76,6 +72,10 @@ public class EntityViewEntity implements SearchTextEntity<EntityView> {
@Column(name = DEVICE_TYPE_PROPERTY)
private String type;
@Enumerated(EnumType.STRING)
@Column(name = ENTITY_TYPE_PROPERTY)
private EntityType entityType;
@Column(name = ModelConstants.ENTITY_VIEW_ENTITY_ID_PROPERTY)
private UUID entityId;

2
dao/src/main/resources/sql/schema-entities.sql

@ -236,7 +236,7 @@ CREATE TABLE IF NOT EXISTS entity_view (
customer_id varchar(31),
type varchar(255),
name varchar(255),
keys varchar(255),
keys varchar(10000000),
start_ts bigint,
end_ts bigint,
search_text varchar(255),

Loading…
Cancel
Save