Restore alarm relations update script. Add Bootstrap upgrade script
# Conflicts: # application/src/main/java/org/thingsboard/server/service/install/SqlDatabaseUpgradeService.java
This commit is contained in:
parent
b84ab58d7b
commit
6c166b9077
@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright © 2016-2021 The Thingsboard Authors
|
* Copyright © 2016-2021 The Thingsboard Authors
|
||||||
*
|
* <p>
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
* <p>
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
* <p>
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@ -475,14 +475,30 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService
|
|||||||
log.info("Updating schema ...");
|
log.info("Updating schema ...");
|
||||||
schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "3.3.2", SCHEMA_UPDATE_SQL);
|
schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "3.3.2", SCHEMA_UPDATE_SQL);
|
||||||
loadSql(schemaUpdateFile, conn);
|
loadSql(schemaUpdateFile, conn);
|
||||||
log.info("Updating server`s public key from HexDec to Base64 in profile for LWM2M...");
|
try {
|
||||||
schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "3.3.2", "schema_update_lwm2m_bootstrap.sql");
|
conn.createStatement().execute("insert into entity_alarm(tenant_id, entity_id, created_time, type, customer_id, alarm_id)" +
|
||||||
loadSql(schemaUpdateFile, conn);
|
" select tenant_id, originator_id, created_time, type, customer_id, id from alarm;");
|
||||||
conn.createStatement().execute("call update_profile_bootstrap();");
|
conn.createStatement().execute("insert into entity_alarm(tenant_id, entity_id, created_time, type, customer_id, alarm_id)" +
|
||||||
log.info("Server`s public key from HexDec to Base64 in profile for LWM2M updated.");
|
" select a.tenant_id, r.from_id, created_time, type, customer_id, id" +
|
||||||
log.info("Updating client`s public key and secret key from HexDec to Base64 for LWM2M...");
|
" from alarm a inner join relation r on r.relation_type_group = 'ALARM' and r.relation_type = 'ANY' and a.id = r.to_id ON CONFLICT DO NOTHING;");
|
||||||
conn.createStatement().execute("call update_device_credentials_to_base64_and_bootstrap();");
|
conn.createStatement().execute("delete from relation r where r.relation_type_group = 'ALARM';");
|
||||||
log.info("Client`s public key and secret key from HexDec to Base64 for LWM2M updated.");
|
} catch (Exception e) {
|
||||||
|
log.error("Failed to update alarm relations!!!", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("Updating lwm2m device profiles ...");
|
||||||
|
try {
|
||||||
|
schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "3.3.2", "schema_update_lwm2m_bootstrap.sql");
|
||||||
|
loadSql(schemaUpdateFile, conn);
|
||||||
|
log.info("Updating server`s public key from HexDec to Base64 in profile for LWM2M...");
|
||||||
|
conn.createStatement().execute("call update_profile_bootstrap();");
|
||||||
|
log.info("Server`s public key from HexDec to Base64 in profile for LWM2M updated.");
|
||||||
|
log.info("Updating client`s public key and secret key from HexDec to Base64 for LWM2M...");
|
||||||
|
conn.createStatement().execute("call update_device_credentials_to_base64_and_bootstrap();");
|
||||||
|
log.info("Client`s public key and secret key from HexDec to Base64 for LWM2M updated.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Failed to update lwm2m profiles!!!", e);
|
||||||
|
}
|
||||||
log.info("Updating schema settings...");
|
log.info("Updating schema settings...");
|
||||||
conn.createStatement().execute("UPDATE tb_schema_settings SET schema_version = 3003003;");
|
conn.createStatement().execute("UPDATE tb_schema_settings SET schema_version = 3003003;");
|
||||||
log.info("Schema updated.");
|
log.info("Schema updated.");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user