Commit 14d7f0af2f38e61681c60cbae7cedf32940498e7
Committed by
Andrew Shvayka
1 parent
866d7c4a
upgrade scripts fix
Showing
2 changed files
with
42 additions
and
0 deletions
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 | +DROP INDEX IF EXISTS idx_alarm_originator_alarm_type; | ||
18 | + | ||
19 | +CREATE INDEX IF NOT EXISTS idx_alarm_originator_alarm_type ON alarm(originator_id, type, start_ts DESC); | ||
20 | + | ||
21 | +CREATE INDEX IF NOT EXISTS idx_device_customer_id ON device(tenant_id, customer_id); | ||
22 | + | ||
23 | +CREATE INDEX IF NOT EXISTS idx_device_customer_id_and_type ON device(tenant_id, customer_id, type); | ||
24 | + | ||
25 | +CREATE INDEX IF NOT EXISTS idx_device_type ON device(tenant_id, type); | ||
26 | + | ||
27 | +CREATE INDEX IF NOT EXISTS idx_asset_customer_id ON asset(tenant_id, customer_id); | ||
28 | + | ||
29 | +CREATE INDEX IF NOT EXISTS idx_asset_customer_id_and_type ON asset(tenant_id, customer_id, type); | ||
30 | + | ||
31 | +CREATE INDEX IF NOT EXISTS idx_asset_type ON asset(tenant_id, type); |
@@ -182,6 +182,17 @@ public class SqlDatabaseUpgradeService implements DatabaseUpgradeService { | @@ -182,6 +182,17 @@ public class SqlDatabaseUpgradeService implements DatabaseUpgradeService { | ||
182 | try { | 182 | try { |
183 | conn.createStatement().execute("ALTER TABLE asset ADD COLUMN label varchar(255)"); //NOSONAR, ignoring because method used to execute thingsboard database upgrade script | 183 | conn.createStatement().execute("ALTER TABLE asset ADD COLUMN label varchar(255)"); //NOSONAR, ignoring because method used to execute thingsboard database upgrade script |
184 | } catch (Exception e) {} | 184 | } catch (Exception e) {} |
185 | + schemaUpdateFile = Paths.get(installScripts.getDataDir(), "upgrade", "2.4.2", SCHEMA_UPDATE_SQL); | ||
186 | + loadSql(schemaUpdateFile, conn); | ||
187 | + try { | ||
188 | + 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 | ||
189 | + } catch (Exception e) {} | ||
190 | + try { | ||
191 | + 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 | ||
192 | + } catch (Exception e) {} | ||
193 | + try { | ||
194 | + 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 | ||
195 | + } catch (Exception e) {} | ||
185 | log.info("Schema updated."); | 196 | log.info("Schema updated."); |
186 | } | 197 | } |
187 | break; | 198 | break; |