From a85dc14805068ac6ab6eab7efd5d10459ee3ebc2 Mon Sep 17 00:00:00 2001
From: "Benjamin, Max (mb388a)" <mb388a@us.att.com>
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) <mb388a@us.att.com>
---
 asdc-controller/src/test/resources/schema.sql | 63 +++++++++++----------------
 1 file changed, 25 insertions(+), 38 deletions(-)

(limited to 'asdc-controller/src/test/resources/schema.sql')

diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index a84b02db63..b17fb5d47c 100644
--- a/asdc-controller/src/test/resources/schema.sql
+++ b/asdc-controller/src/test/resources/schema.sql
@@ -517,36 +517,29 @@ 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,
-`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 `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 `configuration_customization` (
 `model_customization_uuid` varchar(200) not null, 
@@ -560,19 +553,13 @@ create table if not exists `configuration_customization` (
 `configuration_customization_model_customization_uuid` varchar(200) null, 
 primary key (`model_customization_uuid`), 
 index `fk_configuration_customization__configuration_idx` (`configuration_model_uuid` asc), 
-index `fk_configuration_customization__service_proxy_customization_idx`
-(`service_proxy_customization_model_customization_uuid` asc), 
 index `fk_configuration_customization__configuration_customization_idx`
 (`configuration_customization_model_customization_uuid` asc), 
 constraint `fk_configuration_resource_customization__configuration_resour1`
 foreign key (`configuration_model_uuid`) references `configuration` (`model_uuid`)
 on delete cascade on update cascade, 
-constraint `fk_configuration_customization__service_proxy_customization1` foreign
-key (`service_proxy_customization_model_customization_uuid`) references
-`service_proxy_customization` (`model_customization_uuid`)
-on delete cascade on update cascade, constraint
-`fk_configuration_customization__configuration_customization1` foreign
-key (`configuration_customization_model_customization_uuid`) references
+constraint `fk_configuration_customization__configuration_customization1` 
+foreign key (`configuration_customization_model_customization_uuid`) references
 `configuration_customization` (`model_customization_uuid`)
 on delete cascade on update cascade)
 engine = innodb
-- 
cgit 1.2.3-korg

