Merge pull request #13643 from AndriiLandiak/external-id-refactoring
Remove duplicated indexes
This commit is contained in:
		
						commit
						114d9e8771
					
				@ -22,3 +22,16 @@ ALTER TABLE ota_package
 | 
			
		||||
    ADD CONSTRAINT ota_package_external_id_unq_key UNIQUE (tenant_id, external_id);
 | 
			
		||||
 | 
			
		||||
-- UPDATE OTA PACKAGE EXTERNAL ID END
 | 
			
		||||
 | 
			
		||||
-- DROP INDEXES THAT DUPLICATE UNIQUE CONSTRAINT START
 | 
			
		||||
 | 
			
		||||
DROP INDEX IF EXISTS idx_device_external_id;
 | 
			
		||||
DROP INDEX IF EXISTS idx_device_profile_external_id;
 | 
			
		||||
DROP INDEX IF EXISTS idx_asset_external_id;
 | 
			
		||||
DROP INDEX IF EXISTS idx_entity_view_external_id;
 | 
			
		||||
DROP INDEX IF EXISTS idx_rule_chain_external_id;
 | 
			
		||||
DROP INDEX IF EXISTS idx_dashboard_external_id;
 | 
			
		||||
DROP INDEX IF EXISTS idx_customer_external_id;
 | 
			
		||||
DROP INDEX IF EXISTS idx_widgets_bundle_external_id;
 | 
			
		||||
 | 
			
		||||
-- DROP INDEXES THAT DUPLICATE UNIQUE CONSTRAINT END
 | 
			
		||||
 | 
			
		||||
@ -68,7 +68,7 @@ import java.util.stream.Collectors;
 | 
			
		||||
 */
 | 
			
		||||
@Slf4j
 | 
			
		||||
public class CalculatedFieldEntityMessageProcessor extends AbstractContextAwareMsgProcessor {
 | 
			
		||||
    // (1 for result persistence + 1 for the state persistence )
 | 
			
		||||
    // (1 for result persistence + 1 for the state persistence)
 | 
			
		||||
    public static final int CALLBACKS_PER_CF = 2;
 | 
			
		||||
 | 
			
		||||
    final TenantId tenantId;
 | 
			
		||||
 | 
			
		||||
@ -131,7 +131,7 @@ public class PartitionedQueueResponseTemplate<Request extends TbQueueMsg, Respon
 | 
			
		||||
                                    @Override
 | 
			
		||||
                                    public void onFailure(Throwable t) {
 | 
			
		||||
                                        log.error("[{}] Failed to send response {}", requestId, response, t);
 | 
			
		||||
                                        sendErrorResponse(requestId, responseTopic, request, t);
 | 
			
		||||
                                        sendErrorResponse(requestId, tpi, request, t);
 | 
			
		||||
                                        stats.incrementFailed();
 | 
			
		||||
                                    }
 | 
			
		||||
                                });
 | 
			
		||||
@ -158,12 +158,11 @@ public class PartitionedQueueResponseTemplate<Request extends TbQueueMsg, Respon
 | 
			
		||||
        consumer.commit();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void sendErrorResponse(UUID requestId, String responseTopic, Request request, Throwable cause) {
 | 
			
		||||
    private void sendErrorResponse(UUID requestId, TopicPartitionInfo tpi, Request request, Throwable cause) {
 | 
			
		||||
        Response errorResponseMsg = handler.constructErrorResponseMsg(request, cause);
 | 
			
		||||
 | 
			
		||||
        if (errorResponseMsg != null) {
 | 
			
		||||
            errorResponseMsg.getHeaders().put(REQUEST_ID_HEADER, uuidToBytes(requestId));
 | 
			
		||||
            TopicPartitionInfo tpi = TopicPartitionInfo.builder().topic(responseTopic).build();
 | 
			
		||||
            responseProducer.send(tpi, errorResponseMsg, null);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -73,26 +73,8 @@ CREATE INDEX IF NOT EXISTS idx_edge_event_id ON edge_event(id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_rpc_tenant_id_device_id ON rpc(tenant_id, device_id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_device_external_id ON device(tenant_id, external_id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_device_profile_external_id ON device_profile(tenant_id, external_id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_asset_external_id ON asset(tenant_id, external_id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_entity_view_external_id ON entity_view(tenant_id, external_id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_rule_chain_external_id ON rule_chain(tenant_id, external_id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_dashboard_external_id ON dashboard(tenant_id, external_id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_customer_external_id ON customer(tenant_id, external_id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_widgets_bundle_external_id ON widgets_bundle(tenant_id, external_id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_rule_node_external_id ON rule_node(rule_chain_id, external_id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_ota_package_external_id ON ota_package(tenant_id, external_id);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_rule_node_type_id_configuration_version ON rule_node(type, id, configuration_version);
 | 
			
		||||
 | 
			
		||||
CREATE INDEX IF NOT EXISTS idx_api_usage_state_entity_id ON api_usage_state(entity_id);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user