added upgrade script for attributes and latest ts
This commit is contained in:
		
							parent
							
								
									2336cba89a
								
							
						
					
					
						commit
						164185c0f3
					
				
							
								
								
									
										23
									
								
								application/src/main/data/upgrade/3.7.0/schema_update.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								application/src/main/data/upgrade/3.7.0/schema_update.sql
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,23 @@
 | 
			
		||||
--
 | 
			
		||||
-- Copyright © 2016-2024 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.
 | 
			
		||||
--
 | 
			
		||||
 | 
			
		||||
-- UPDATE PUBLIC CUSTOMERS START
 | 
			
		||||
 | 
			
		||||
CREATE SEQUENCE IF NOT EXISTS attribute_kv_version_seq cache 1000;
 | 
			
		||||
CREATE SEQUENCE IF NOT EXISTS ts_kv_latest_version_seq cache 1000;
 | 
			
		||||
 | 
			
		||||
ALTER TABLE attribute_kv ADD COLUMN version bigint default 0;
 | 
			
		||||
ALTER TABLE ts_kv_latest ADD COLUMN version bigint default 0;
 | 
			
		||||
@ -137,6 +137,10 @@ public class ThingsboardInstallService {
 | 
			
		||||
                            entityDatabaseSchemaService.createCustomerTitleUniqueConstraintIfNotExists();
 | 
			
		||||
                            systemDataLoaderService.updateDefaultNotificationConfigs(false);
 | 
			
		||||
                            systemDataLoaderService.updateSecuritySettings();
 | 
			
		||||
                            break;
 | 
			
		||||
                        case "3.7.0":
 | 
			
		||||
                            log.info("Upgrading ThingsBoard from version 3.7.0 to 3.7.1 ...");
 | 
			
		||||
                            databaseEntitiesUpgradeService.upgradeDatabase("3.7.0");
 | 
			
		||||
                            //TODO DON'T FORGET to update switch statement in the CacheCleanupService if you need to clear the cache
 | 
			
		||||
                            break;
 | 
			
		||||
                        default:
 | 
			
		||||
 | 
			
		||||
@ -121,6 +121,9 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService
 | 
			
		||||
            case "3.6.4":
 | 
			
		||||
                updateSchema("3.6.4", 3006004, "3.7.0", 3007000, null);
 | 
			
		||||
                break;
 | 
			
		||||
            case "3.7.0":
 | 
			
		||||
                updateSchema("3.7.0", 3007000, "3.7.1", 3007001, null);
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                throw new RuntimeException("Unable to upgrade SQL database, unsupported fromVersion: " + fromVersion);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -61,6 +61,10 @@ public class DefaultCacheCleanupService implements CacheCleanupService {
 | 
			
		||||
                log.info("Clearing cache to upgrade from version 3.6.4 to 3.7.0");
 | 
			
		||||
                clearAll();
 | 
			
		||||
                break;
 | 
			
		||||
            case "3.7.0":
 | 
			
		||||
                log.info("Clearing cache to upgrade from version 3.7.0 to 3.7.1");
 | 
			
		||||
                clearAll();
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                //Do nothing, since cache cleanup is optional.
 | 
			
		||||
        }
 | 
			
		||||
@ -81,7 +85,7 @@ public class DefaultCacheCleanupService implements CacheCleanupService {
 | 
			
		||||
        if (redisTemplate.isPresent()) {
 | 
			
		||||
            log.info("Flushing all caches");
 | 
			
		||||
            redisTemplate.get().execute((RedisCallback<Object>) connection -> {
 | 
			
		||||
                connection.flushAll();
 | 
			
		||||
                connection.serverCommands().flushAll();
 | 
			
		||||
                return null;
 | 
			
		||||
            });
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user