Modified DB Upgrade script for OptimizationModels
[policy/engine.git] / packages / base / src / files / install / mysql / data / 180601_upgrade_script.sql
1 /*-
2 * ============LICENSE_START=======================================================
3 * ONAP Policy Engine
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
19 */
20 use onap_sdk;
21
22 drop table if exists `onap_sdk`.`optimizationmodels`;
23 create table `onap_sdk`.`optimizationmodels` (
24 `id` int(11) not null auto_increment,
25 `modelname` varchar(767) not null,
26 `description` varchar(1024) default null,
27 `dependency` varchar(1024) default null,
28 `imported_by` varchar(45) not null,
29 `attributes` longtext,
30 `ref_attributes` longtext,
31 `sub_attributes` longtext,
32 `version` varchar(45) default null,
33 `annotation` longtext,
34 `enumValues` longtext, 
35 `dataOrderInfo` varchar(2000) DEFAULT NULL,
36 primary key (`id`),
37 unique key `optimizationmodels_uniq` (`modelname`,`version`)
38 );
39
40 drop table if exists `onap_sdk`.`MicroServiceHeaderDefaults`;
41 CREATE TABLE `onap_sdk`.`MicroServiceHeaderDefaults` (
42   `ID` int(11) NOT NULL AUTO_INCREMENT,
43   `onapName` varchar(255) DEFAULT NULL,
44   `guard` varchar(255) DEFAULT NULL,
45   `priority` varchar(3) DEFAULT NULL,
46   `riskType` varchar(255) DEFAULT NULL,  
47   `riskLevel` varchar(3) DEFAULT NULL,   
48   `modelName` varchar(1024) NOT NULL,
49   PRIMARY KEY (`ID`)
50 );
51
52 ALTER TABLE `onap_sdk`.`microservicemodels` 
53 ADD COLUMN `dataOrderInfo` VARCHAR(2000) NULL DEFAULT 'Null' AFTER `enumValues`;
54
55 INSERT INTO `onap_sdk`.`optimizationmodels` (`modelname`, `description`, `dependency`, `imported_by`, `attributes`, `ref_attributes`, `sub_attributes`, `version`, `annotation`, `enumValues`, `dataOrderInfo`) VALUES ('hpaPolicy', 'CSIT Tests Model', '[]', 'demo', 'identity=string:defaultValue-null:required-true:MANY-false,resources=string:defaultValue-null:required-true:MANY-false', 'policyScope=MANY-true,policyType=POLICYTYPE:MANY-false,flavorFeatures=flavorFeatures-properties:MANY-true', '{\"flavorProperties-properties\":{\"score\":\"string:defaultValue-null:required-true:MANY-false\",\"featureAttributes\":\"featureAttributes-properties:required-false:MANY-true\",\"mandatory\":\"string:defaultValue-null:required-true:MANY-false\",\"hpaFeature\":\"string:defaultValue-null:required-true:MANY-false\",\"architecture\":\"string:defaultValue-null:required-true:MANY-false\"},\"flavorFeatures-properties\":{\"flavorProperties\":\"flavorProperties-properties:required-false:MANY-true\",\"flavorLabel\":\"string:defaultValue-null:required-true:MANY-false\"},\"featureAttributes-properties\":{\"unit\":\"string:defaultValue-null:required-true:MANY-false\",\"attribute\":\"string:defaultValue-null:required-true:MANY-false\",\"value\":\"string:defaultValue-null:required-true:MANY-false\",\"operator\":\"OPERATOR:required-true:MANY-false\"}}\n', 'CSIT', 'policyScope=matching-true', 'OPERATOR=[<,<equal-sign,>,>equal-sign,equal-sign,!equal-sign,any,all,subset,], POLICYTYPE=[hpaPolicy,]', '\"[resources,identity,policyScope,policyType,flavorFeatures,flavorLabel,flavorProperties,architecture,hpaFeature,mandatory,score,featureAttributes,attribute,operator,unit,value]\"');
56