From a85dc14805068ac6ab6eab7efd5d10459ee3ebc2 Mon Sep 17 00:00:00 2001 From: "Benjamin, Max (mb388a)" Date: Fri, 11 Jan 2019 21:14:32 -0500 Subject: Service Proxy Consolidation - Updated ServiceProxyResourceCustomization to remove the ID column - Removed setConfigurationResourceCustomization from serviceProxyResource since that relationship doesn't exist anymore - Updated ServiceProxy resource to remove the object dependencies between ServiceProxyCustomization and ConfigurationResourceCustomization - Removed the delete statement since this is causing the test to fail because the service table doesn't exist yet - Updated configuration_customization to drop the serviceProxyCustomization FK - Added migration script to consolidate the ServiceProxy and ServiceProxyCustomization into a single table and migrate the data. - Code changes to support consolidating the ServiceProxy and ServiceProxyCustomization table into a single table Change-Id: I1e49cb22c8b667f157dd1c349b5e36fd06236630 Issue-ID: SO-1380 Signed-off-by: Benjamin, Max (mb388a) --- .../V5.1__ServiceProxyTableConsolidation.sql | 44 ++++++++++++++++++ .../src/test/resources/schema.sql | 52 ++++++++++------------ 2 files changed, 67 insertions(+), 29 deletions(-) create mode 100644 adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.1__ServiceProxyTableConsolidation.sql (limited to 'adapters') diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.1__ServiceProxyTableConsolidation.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.1__ServiceProxyTableConsolidation.sql new file mode 100644 index 0000000000..c196f8f6e3 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.1__ServiceProxyTableConsolidation.sql @@ -0,0 +1,44 @@ +use catalogdb; + +/* Consolidate Service_Proxy_Customization and Service_Proxy tables into a new table also called Service_Proxy_Customization */ + +ALTER TABLE service_proxy_customization DROP FOREIGN KEY fk_service_proxy_resource_customization__service1; + +ALTER TABLE service_proxy_customization DROP FOREIGN KEY fk_spr_customization__service_proxy_resource1; + +ALTER TABLE configuration_customization DROP FOREIGN KEY fk_configuration_customization__service_proxy_customization1; + +CREATE TABLE IF NOT EXISTS `service_proxy_customization_temp` ( + `MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL, + `MODEL_UUID` VARCHAR(200) NOT NULL, + `MODEL_INVARIANT_UUID` VARCHAR(200) NOT NULL, + `MODEL_VERSION` VARCHAR(20) NOT NULL, + `MODEL_NAME` VARCHAR(200) NOT NULL, + `TOSCA_NODE_TYPE` VARCHAR(200) NOT NULL, + `DESCRIPTION` VARCHAR(1200) NULL, + `SOURCE_SERVICE_MODEL_UUID` VARCHAR(200) NOT NULL, + `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`), + INDEX `fk_service_proxy_customization__service1_idx` (`SOURCE_SERVICE_MODEL_UUID` ASC), + UNIQUE INDEX `UK_service_proxy_customization` (`MODEL_CUSTOMIZATION_UUID` ASC), + INDEX `fk_service_proxy_customization__serv_prox_to_serv` (`MODEL_CUSTOMIZATION_UUID` ASC), + CONSTRAINT `fk_service_proxy_resource_customization__service1` + FOREIGN KEY (`SOURCE_SERVICE_MODEL_UUID`) + REFERENCES `catalogdb`.`service` (`MODEL_UUID`) + ON DELETE CASCADE + ON UPDATE CASCADE) +ENGINE = InnoDB +AUTO_INCREMENT = 20654 +DEFAULT CHARACTER SET = latin1; + +INSERT INTO catalogdb.service_proxy_customization_temp (model_customization_uuid,model_instance_name,model_uuid,model_invariant_uuid,model_version,model_name,tosca_node_type,description,source_service_model_uuid) +SELECT T1.model_customization_uuid, T1.model_instance_name,T2.model_uuid, T2.model_invariant_uuid, T2.model_version, T2.model_name, T1.tosca_node_type, T2.description, T1.source_service_model_uuid + FROM catalogdb.service_proxy_customization T1 + JOIN catalogdb.service_proxy T2 ON T1.service_proxy_model_uuid = T2.model_uuid; + +DROP TABLE service_proxy_customization; + +DROP TABLE service_proxy; + +RENAME TABLE service_proxy_customization_temp TO service_proxy_customization; diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql index 0c67123f56..72810d6f3c 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql @@ -502,36 +502,30 @@ default character set = latin1; engine = innodb auto_increment = 20654 default character set = latin1; - create table if not exists `service_proxy` ( - `model_uuid` varchar(200) not null, - `model_invariant_uuid` varchar(200) not null, - `model_version` varchar(20) not null, - `model_name` varchar(200) not null, - `description` varchar(1200) null, - `creation_timestamp` datetime not null default current_timestamp, - primary key (`model_uuid`)) - engine = innodb auto_increment = 20654 - default character set = latin1; + CREATE TABLE IF NOT EXISTS `service_proxy_customization` ( + `MODEL_CUSTOMIZATION_UUID` VARCHAR(200) NOT NULL, + `MODEL_INSTANCE_NAME` VARCHAR(200) NOT NULL, + `MODEL_UUID` VARCHAR(200) NOT NULL, + `MODEL_INVARIANT_UUID` VARCHAR(200) NOT NULL, + `MODEL_VERSION` VARCHAR(20) NOT NULL, + `MODEL_NAME` VARCHAR(200) NOT NULL, + `TOSCA_NODE_TYPE` VARCHAR(200) NOT NULL, + `DESCRIPTION` VARCHAR(1200) NULL, + `SOURCE_SERVICE_MODEL_UUID` VARCHAR(200) NOT NULL, + `CREATION_TIMESTAMP` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`), + INDEX `fk_service_proxy_customization__service1_idx` (`SOURCE_SERVICE_MODEL_UUID` ASC), + UNIQUE INDEX `UK_service_proxy_customization` (`MODEL_CUSTOMIZATION_UUID` ASC), + INDEX `fk_service_proxy_customization__serv_prox_to_serv` (`MODEL_CUSTOMIZATION_UUID` ASC), + CONSTRAINT `fk_service_proxy_resource_customization__service1` + FOREIGN KEY (`SOURCE_SERVICE_MODEL_UUID`) + REFERENCES `service` (`MODEL_UUID`) + ON DELETE CASCADE + ON UPDATE CASCADE) +ENGINE = InnoDB +AUTO_INCREMENT = 20654 +DEFAULT CHARACTER SET = latin1; -create table if not exists `service_proxy_customization` ( -`model_customization_uuid` varchar(200) not null, -`model_instance_name` varchar(200) not null, -`tosca_node_type` varchar(200) not null, -`source_service_model_uuid` varchar(200) not null, -`creation_timestamp` datetime not null default current_timestamp, -`service_proxy_model_uuid` varchar(200) not null, -primary key (`model_customization_uuid`), -index `fk_service_proxy_customization__service_proxy1_idx` (`service_proxy_model_uuid` asc), -index `fk_service_proxy_customization__service1_idx` (`source_service_model_uuid` asc), -constraint`fk_spr_customization__service_proxy_resource1` -foreign key (`service_proxy_model_uuid`) references `service_proxy` (`model_uuid`) -on delete cascade on update cascade, -constraint `fk_service_proxy_resource_customization__service1` -foreign key (`source_service_model_uuid`) references `service` -(`model_uuid`) on delete cascade on update cascade) -engine = innodb -auto_increment = 20654 -default character set = latin1; create table if not exists `configuration_customization` ( `model_customization_uuid` varchar(200) not null, -- cgit 1.2.3-korg