Cleanup upgrade scripts
This commit is contained in:
		
							parent
							
								
									757c887034
								
							
						
					
					
						commit
						cedc7d2e46
					
				@ -14,82 +14,3 @@
 | 
			
		||||
-- limitations under the License.
 | 
			
		||||
--
 | 
			
		||||
 | 
			
		||||
-- UPDATE SAVE TIME SERIES NODES START
 | 
			
		||||
 | 
			
		||||
UPDATE rule_node
 | 
			
		||||
SET configuration = (
 | 
			
		||||
    (configuration::jsonb - 'skipLatestPersistence')
 | 
			
		||||
        || jsonb_build_object(
 | 
			
		||||
            'processingSettings', jsonb_build_object(
 | 
			
		||||
                    'type',       'ADVANCED',
 | 
			
		||||
                    'timeseries',       jsonb_build_object('type', 'ON_EVERY_MESSAGE'),
 | 
			
		||||
                    'latest',           jsonb_build_object('type', 'SKIP'),
 | 
			
		||||
                    'webSockets',       jsonb_build_object('type', 'ON_EVERY_MESSAGE'),
 | 
			
		||||
                    'calculatedFields', jsonb_build_object('type', 'ON_EVERY_MESSAGE')
 | 
			
		||||
                                   )
 | 
			
		||||
           )
 | 
			
		||||
    )::text,
 | 
			
		||||
    configuration_version = 1
 | 
			
		||||
WHERE type = 'org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode'
 | 
			
		||||
  AND configuration_version = 0
 | 
			
		||||
  AND configuration::jsonb ->> 'skipLatestPersistence' = 'true';
 | 
			
		||||
 | 
			
		||||
UPDATE rule_node
 | 
			
		||||
SET configuration = (
 | 
			
		||||
    (configuration::jsonb - 'skipLatestPersistence')
 | 
			
		||||
        || jsonb_build_object(
 | 
			
		||||
            'processingSettings', jsonb_build_object(
 | 
			
		||||
                    'type', 'ON_EVERY_MESSAGE'
 | 
			
		||||
                                   )
 | 
			
		||||
           )
 | 
			
		||||
    )::text,
 | 
			
		||||
    configuration_version = 1
 | 
			
		||||
WHERE type = 'org.thingsboard.rule.engine.telemetry.TbMsgTimeseriesNode'
 | 
			
		||||
  AND configuration_version = 0
 | 
			
		||||
  AND (configuration::jsonb ->> 'skipLatestPersistence' != 'true' OR configuration::jsonb ->> 'skipLatestPersistence' IS NULL);
 | 
			
		||||
 | 
			
		||||
-- UPDATE SAVE TIME SERIES NODES END
 | 
			
		||||
 | 
			
		||||
-- UPDATE SAVE ATTRIBUTES NODES START
 | 
			
		||||
 | 
			
		||||
UPDATE rule_node
 | 
			
		||||
SET configuration = (
 | 
			
		||||
    configuration::jsonb
 | 
			
		||||
        || jsonb_build_object(
 | 
			
		||||
            'processingSettings', jsonb_build_object('type', 'ON_EVERY_MESSAGE')
 | 
			
		||||
           )
 | 
			
		||||
    )::text,
 | 
			
		||||
    configuration_version = 3
 | 
			
		||||
WHERE type = 'org.thingsboard.rule.engine.telemetry.TbMsgAttributesNode'
 | 
			
		||||
  AND configuration_version = 2;
 | 
			
		||||
 | 
			
		||||
-- UPDATE SAVE ATTRIBUTES NODES END
 | 
			
		||||
 | 
			
		||||
ALTER TABLE api_usage_state ADD COLUMN IF NOT EXISTS version BIGINT DEFAULT 1;
 | 
			
		||||
 | 
			
		||||
-- UPDATE TENANT PROFILE CALCULATED FIELD LIMITS START
 | 
			
		||||
 | 
			
		||||
UPDATE tenant_profile
 | 
			
		||||
SET profile_data = profile_data
 | 
			
		||||
    || jsonb_build_object(
 | 
			
		||||
        'configuration', profile_data->'configuration' || jsonb_build_object(
 | 
			
		||||
        'maxCalculatedFieldsPerEntity', COALESCE(profile_data->'configuration'->>'maxCalculatedFieldsPerEntity', '5')::bigint,
 | 
			
		||||
        'maxArgumentsPerCF', COALESCE(profile_data->'configuration'->>'maxArgumentsPerCF', '10')::bigint,
 | 
			
		||||
        'maxDataPointsPerRollingArg', COALESCE(profile_data->'configuration'->>'maxDataPointsPerRollingArg', '1000')::bigint,
 | 
			
		||||
        'maxStateSizeInKBytes', COALESCE(profile_data->'configuration'->>'maxStateSizeInKBytes', '32')::bigint,
 | 
			
		||||
        'maxSingleValueArgumentSizeInKBytes', COALESCE(profile_data->'configuration'->>'maxSingleValueArgumentSizeInKBytes', '2')::bigint
 | 
			
		||||
        )
 | 
			
		||||
    )
 | 
			
		||||
WHERE profile_data->'configuration'->>'maxCalculatedFieldsPerEntity' IS NULL;
 | 
			
		||||
 | 
			
		||||
-- UPDATE TENANT PROFILE CALCULATED FIELD LIMITS END
 | 
			
		||||
 | 
			
		||||
-- UPDATE TENANT PROFILE DEBUG DURATION START
 | 
			
		||||
 | 
			
		||||
UPDATE tenant_profile
 | 
			
		||||
SET profile_data = jsonb_set(profile_data, '{configuration,maxDebugModeDurationMinutes}', '15', true)
 | 
			
		||||
WHERE
 | 
			
		||||
    profile_data->'configuration' ? 'maxDebugModeDurationMinutes' = false
 | 
			
		||||
    OR (profile_data->'configuration'->>'maxDebugModeDurationMinutes')::int = 0;
 | 
			
		||||
 | 
			
		||||
-- UPDATE TENANT PROFILE DEBUG DURATION END
 | 
			
		||||
 | 
			
		||||
@ -32,7 +32,7 @@ public class DefaultDatabaseSchemaSettingsService implements DatabaseSchemaSetti
 | 
			
		||||
 | 
			
		||||
    // This list should include all versions which are compatible for the upgrade.
 | 
			
		||||
    // The compatibility cycle usually breaks when we have some scripts written in Java that may not work after new release.
 | 
			
		||||
    private static final List<String> SUPPORTED_VERSIONS_FOR_UPGRADE = List.of("3.9.0", "3.9.1");
 | 
			
		||||
    private static final List<String> SUPPORTED_VERSIONS_FOR_UPGRADE = List.of("4.0.0");
 | 
			
		||||
 | 
			
		||||
    private final ProjectInfo projectInfo;
 | 
			
		||||
    private final JdbcTemplate jdbcTemplate;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user