added upgrade from version 2.5.0
This commit is contained in:
parent
ee7c4f6e7f
commit
f8a355fec8
@ -133,13 +133,20 @@ public class ThingsboardInstallService {
|
|||||||
databaseEntitiesUpgradeService.upgradeDatabase("2.4.2");
|
databaseEntitiesUpgradeService.upgradeDatabase("2.4.2");
|
||||||
|
|
||||||
case "2.4.3":
|
case "2.4.3":
|
||||||
log.info("Upgrading ThingsBoard from version 2.4.3 to 2.5 ...");
|
log.info("Upgrading ThingsBoard from version 2.4.3 to 2.5.0 ...");
|
||||||
|
|
||||||
if (databaseTsUpgradeService != null) {
|
if (databaseTsUpgradeService != null) {
|
||||||
databaseTsUpgradeService.upgradeDatabase("2.4.3");
|
databaseTsUpgradeService.upgradeDatabase("2.4.3");
|
||||||
}
|
}
|
||||||
databaseEntitiesUpgradeService.upgradeDatabase("2.4.3");
|
databaseEntitiesUpgradeService.upgradeDatabase("2.4.3");
|
||||||
|
|
||||||
|
case "2.5.0":
|
||||||
|
log.info("Upgrading ThingsBoard from version 2.5.0 to 2.5.1 ...");
|
||||||
|
if (databaseTsUpgradeService != null) {
|
||||||
|
databaseTsUpgradeService.upgradeDatabase("2.5.0");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
log.info("Updating system data...");
|
log.info("Updating system data...");
|
||||||
|
|
||||||
systemDataLoaderService.deleteSystemWidgetBundle("charts");
|
systemDataLoaderService.deleteSystemWidgetBundle("charts");
|
||||||
|
|||||||
@ -37,8 +37,6 @@ public class PsqlTsDatabaseSchemaService extends SqlAbstractDatabaseSchemaServic
|
|||||||
@Override
|
@Override
|
||||||
public void createDatabaseSchema() throws Exception {
|
public void createDatabaseSchema() throws Exception {
|
||||||
super.createDatabaseSchema();
|
super.createDatabaseSchema();
|
||||||
if (partitionType.equals("INDEFINITE")) {
|
executeQuery("CREATE TABLE IF NOT EXISTS ts_kv_indefinite PARTITION OF ts_kv DEFAULT;");
|
||||||
executeQuery("CREATE TABLE ts_kv_indefinite PARTITION OF ts_kv DEFAULT;");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,8 +99,6 @@ public class PsqlTsDatabaseUpgradeService extends AbstractSqlTsDatabaseUpgradeSe
|
|||||||
executeQuery(conn, CALL_CREATE_PARTITION_TS_KV_TABLE);
|
executeQuery(conn, CALL_CREATE_PARTITION_TS_KV_TABLE);
|
||||||
if (!partitionType.equals("INDEFINITE")) {
|
if (!partitionType.equals("INDEFINITE")) {
|
||||||
executeQuery(conn, "call create_partitions('" + partitionType + "')");
|
executeQuery(conn, "call create_partitions('" + partitionType + "')");
|
||||||
} else {
|
|
||||||
executeQuery(conn, "CREATE TABLE IF NOT EXISTS ts_kv_indefinite PARTITION OF ts_kv DEFAULT;");
|
|
||||||
}
|
}
|
||||||
executeQuery(conn, CALL_CREATE_TS_KV_DICTIONARY_TABLE);
|
executeQuery(conn, CALL_CREATE_TS_KV_DICTIONARY_TABLE);
|
||||||
executeQuery(conn, CALL_INSERT_INTO_DICTIONARY);
|
executeQuery(conn, CALL_INSERT_INTO_DICTIONARY);
|
||||||
@ -194,6 +192,12 @@ public class PsqlTsDatabaseUpgradeService extends AbstractSqlTsDatabaseUpgradeSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "2.5.0":
|
||||||
|
try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
|
||||||
|
executeQuery(conn, "CREATE TABLE IF NOT EXISTS ts_kv_indefinite PARTITION OF ts_kv DEFAULT;");
|
||||||
|
executeQuery(conn, "UPDATE tb_schema_settings SET schema_version = 2005001");
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
|
throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -175,6 +175,11 @@ public class TimescaleTsDatabaseUpgradeService extends AbstractSqlTsDatabaseUpgr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "2.5.0":
|
||||||
|
try (Connection conn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword)) {
|
||||||
|
executeQuery(conn, "UPDATE tb_schema_settings SET schema_version = 2005001");
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
|
throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -90,7 +90,7 @@ public class JpaPsqlTimeseriesDao extends AbstractChunkedAggregationTimeseriesDa
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void savePartitionIfNotExist(long ts) {
|
private void savePartitionIfNotExist(long ts) {
|
||||||
if (!tsFormat.equals(SqlTsPartitionDate.INDEFINITE)) {
|
if (!tsFormat.equals(SqlTsPartitionDate.INDEFINITE) && ts >= 0) {
|
||||||
LocalDateTime time = LocalDateTime.ofInstant(Instant.ofEpochMilli(ts), ZoneOffset.UTC);
|
LocalDateTime time = LocalDateTime.ofInstant(Instant.ofEpochMilli(ts), ZoneOffset.UTC);
|
||||||
LocalDateTime localDateTimeStart = tsFormat.trancateTo(time);
|
LocalDateTime localDateTimeStart = tsFormat.trancateTo(time);
|
||||||
long partitionStartTs = toMills(localDateTimeStart);
|
long partitionStartTs = toMills(localDateTimeStart);
|
||||||
|
|||||||
@ -52,7 +52,7 @@ CREATE TABLE IF NOT EXISTS tb_schema_settings
|
|||||||
CONSTRAINT tb_schema_settings_pkey PRIMARY KEY (schema_version)
|
CONSTRAINT tb_schema_settings_pkey PRIMARY KEY (schema_version)
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO tb_schema_settings (schema_version) VALUES (2005000) ON CONFLICT (schema_version) DO UPDATE SET schema_version = 2005000;
|
INSERT INTO tb_schema_settings (schema_version) VALUES (2005001) ON CONFLICT (schema_version) DO UPDATE SET schema_version = 2005001;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION to_uuid(IN entity_id varchar, OUT uuid_id uuid) AS
|
CREATE OR REPLACE FUNCTION to_uuid(IN entity_id varchar, OUT uuid_id uuid) AS
|
||||||
$$
|
$$
|
||||||
|
|||||||
@ -53,7 +53,7 @@ CREATE TABLE IF NOT EXISTS tb_schema_settings
|
|||||||
CONSTRAINT tb_schema_settings_pkey PRIMARY KEY (schema_version)
|
CONSTRAINT tb_schema_settings_pkey PRIMARY KEY (schema_version)
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO tb_schema_settings (schema_version) VALUES (2005000) ON CONFLICT (schema_version) DO UPDATE SET schema_version = 2005000;
|
INSERT INTO tb_schema_settings (schema_version) VALUES (2005001) ON CONFLICT (schema_version) DO UPDATE SET schema_version = 2005001;
|
||||||
|
|
||||||
CREATE OR REPLACE PROCEDURE drop_partitions_by_max_ttl(IN partition_type varchar, IN system_ttl bigint, INOUT deleted bigint)
|
CREATE OR REPLACE PROCEDURE drop_partitions_by_max_ttl(IN partition_type varchar, IN system_ttl bigint, INOUT deleted bigint)
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user