upgrade scripts fix
This commit is contained in:
parent
866d7c4a2c
commit
14d7f0af2f
31
application/src/main/data/upgrade/2.4.2/schema_update.sql
Normal file
31
application/src/main/data/upgrade/2.4.2/schema_update.sql
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
--
|
||||||
|
-- Copyright © 2016-2019 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.
|
||||||
|
--
|
||||||
|
|
||||||
|
DROP INDEX IF EXISTS idx_alarm_originator_alarm_type;
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_alarm_originator_alarm_type ON alarm(originator_id, type, start_ts DESC);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_device_customer_id ON device(tenant_id, customer_id);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_device_customer_id_and_type ON device(tenant_id, customer_id, type);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_device_type ON device(tenant_id, type);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_asset_customer_id ON asset(tenant_id, customer_id);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_asset_customer_id_and_type ON asset(tenant_id, customer_id, type);
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_asset_type ON asset(tenant_id, type);
|
||||||
@ -182,6 +182,17 @@ public class SqlDatabaseUpgradeService implements DatabaseUpgradeService {
|
|||||||
try {
|
try {
|
||||||
conn.createStatement().execute("ALTER TABLE asset ADD COLUMN label varchar(255)"); //NOSONAR, ignoring because method used to execute thingsboard database upgrade script
|
conn.createStatement().execute("ALTER TABLE asset ADD COLUMN label varchar(255)"); //NOSONAR, ignoring because method used to execute thingsboard database upgrade script
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
|
schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "2.4.2", SCHEMA_UPDATE_SQL);
|
||||||
|
loadSql(schemaUpdateFile, conn);
|
||||||
|
try {
|
||||||
|
conn.createStatement().execute("ALTER TABLE device ADD CONSTRAINT device_name_unq_key UNIQUE (tenant_id, name)"); //NOSONAR, ignoring because method used to execute thingsboard database upgrade script
|
||||||
|
} catch (Exception e) {}
|
||||||
|
try {
|
||||||
|
conn.createStatement().execute("ALTER TABLE device_credentials ADD CONSTRAINT device_credentials_id_unq_key UNIQUE (credentials_id)"); //NOSONAR, ignoring because method used to execute thingsboard database upgrade script
|
||||||
|
} catch (Exception e) {}
|
||||||
|
try {
|
||||||
|
conn.createStatement().execute("ALTER TABLE asset ADD CONSTRAINT asset_name_unq_key UNIQUE (tenant_id, name)"); //NOSONAR, ignoring because method used to execute thingsboard database upgrade script
|
||||||
|
} catch (Exception e) {}
|
||||||
log.info("Schema updated.");
|
log.info("Schema updated.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user