Commit d7a6865188fbae153e85915deb8d389d22b070fa

Authored by xp.Huang
1 parent f879c48d

fix: 升级优化

@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 -- 15 --
16 16
17 -- NOTIFICATIONS UPDATE START 17 -- NOTIFICATIONS UPDATE START
18 - 18 +ALTER TABLE device_profile ADD is_data_combination boolean DEFAULT false;
19 ALTER TABLE notification ADD COLUMN IF NOT EXISTS delivery_method VARCHAR(50) NOT NULL default 'WEB'; 19 ALTER TABLE notification ADD COLUMN IF NOT EXISTS delivery_method VARCHAR(50) NOT NULL default 'WEB';
20 20
21 DROP INDEX IF EXISTS idx_notification_recipient_id_created_time; 21 DROP INDEX IF EXISTS idx_notification_recipient_id_created_time;
@@ -33,6 +33,7 @@ import org.thingsboard.server.common.data.page.PageDataIterable; @@ -33,6 +33,7 @@ import org.thingsboard.server.common.data.page.PageDataIterable;
33 import org.thingsboard.server.common.data.query.DynamicValue; 33 import org.thingsboard.server.common.data.query.DynamicValue;
34 import org.thingsboard.server.common.data.query.FilterPredicateValue; 34 import org.thingsboard.server.common.data.query.FilterPredicateValue;
35 import org.thingsboard.server.dao.device.DeviceConnectivityConfiguration; 35 import org.thingsboard.server.dao.device.DeviceConnectivityConfiguration;
  36 +import org.thingsboard.server.dao.edge.EdgeEventDao;
36 import org.thingsboard.server.dao.rule.RuleChainService; 37 import org.thingsboard.server.dao.rule.RuleChainService;
37 import org.thingsboard.server.dao.settings.AdminSettingsService; 38 import org.thingsboard.server.dao.settings.AdminSettingsService;
38 import org.thingsboard.server.dao.sql.JpaExecutorService; 39 import org.thingsboard.server.dao.sql.JpaExecutorService;
@@ -67,9 +68,16 @@ public class DefaultDataUpdateService implements DataUpdateService { @@ -67,9 +68,16 @@ public class DefaultDataUpdateService implements DataUpdateService {
67 @Autowired 68 @Autowired
68 DeviceConnectivityConfiguration connectivityConfiguration; 69 DeviceConnectivityConfiguration connectivityConfiguration;
69 70
  71 + @Autowired
  72 + private EdgeEventDao edgeEventDao;
  73 +
70 @Override 74 @Override
71 public void updateData(String fromVersion) throws Exception { 75 public void updateData(String fromVersion) throws Exception {
72 switch (fromVersion) { 76 switch (fromVersion) {
  77 + case "3.5.1":
  78 + log.info("Updating data from version 3.5.1 to 3.6.0 ...");
  79 + migrateEdgeEvents("Starting edge events migration - adding seq_id column. ");
  80 + break;
73 case "3.6.0": 81 case "3.6.0":
74 log.info("Updating data from version 3.6.0 to 3.6.1 ..."); 82 log.info("Updating data from version 3.6.0 to 3.6.1 ...");
75 migrateDeviceConnectivity(); 83 migrateDeviceConnectivity();
@@ -79,6 +87,15 @@ public class DefaultDataUpdateService implements DataUpdateService { @@ -79,6 +87,15 @@ public class DefaultDataUpdateService implements DataUpdateService {
79 } 87 }
80 } 88 }
81 89
  90 + private void migrateEdgeEvents(String logPrefix) {
  91 + boolean skipEdgeEventsMigration = getEnv("TB_SKIP_EDGE_EVENTS_MIGRATION", false);
  92 + if (!skipEdgeEventsMigration) {
  93 + log.info(logPrefix + "Can be skipped with TB_SKIP_EDGE_EVENTS_MIGRATION env variable set to true");
  94 + edgeEventDao.migrateEdgeEvents();
  95 + } else {
  96 + log.info("Skipping edge events migration");
  97 + }
  98 + }
82 private void migrateDeviceConnectivity() { 99 private void migrateDeviceConnectivity() {
83 if (adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "connectivity") == null) { 100 if (adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "connectivity") == null) {
84 AdminSettings connectivitySettings = new AdminSettings(); 101 AdminSettings connectivitySettings = new AdminSettings();