Change Management Schedule Optimization 11/67911/1
authorRamaPrasad Amaranarayana (ra5425) <ra5425@att.com>
Wed, 19 Sep 2018 21:59:48 +0000 (17:59 -0400)
committerRamaPrasad Amaranarayana (ra5425) <ra5425@att.com>
Wed, 19 Sep 2018 21:59:48 +0000 (17:59 -0400)
Adding Database Project for Change Management Schedule Optimization

Change-Id: I03370ea4d80ed0444f986b8c7e9e32dbad206106
Issue-ID: OPTFRA-351
Signed-off-by: RamaPrasad Amaranarayana (ra5425) <ra5425@att.com>
cmso-database/.gitignore [new file with mode: 0644]
cmso-database/docker/Dockerfile [new file with mode: 0644]
cmso-database/etc/config/liquibase.properties [new file with mode: 0644]
cmso-database/pom.xml [new file with mode: 0644]
cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseApplication.java [new file with mode: 0644]
cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseData.java [new file with mode: 0644]
cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1-schema.sql [new file with mode: 0644]
cmso-database/src/main/resources/cmso-liquibase-changeLog.xml [new file with mode: 0644]
cmso-database/src/test/java/org/onap/optf/cmso/liquibase/LiquibaseApplicationTests.java [new file with mode: 0644]
cmso-database/src/test/resources/application-test.properties [new file with mode: 0644]

diff --git a/cmso-database/.gitignore b/cmso-database/.gitignore
new file mode 100644 (file)
index 0000000..b83d222
--- /dev/null
@@ -0,0 +1 @@
+/target/
diff --git a/cmso-database/docker/Dockerfile b/cmso-database/docker/Dockerfile
new file mode 100644 (file)
index 0000000..40251ec
--- /dev/null
@@ -0,0 +1,11 @@
+FROM anapsix/alpine-java:8_jdk
+
+ENV DBUPGRADE_HOME=/opt/app/dbupgrade
+
+VOLUME /volume/config
+VOLUME /volume/logs
+
+ADD target/docker-liquibase.jar ${DBUPGRADE_HOME}/lib/docker-liquibase.jar
+ADD bin ${DBUPGRADE_HOME}/bin
+
+ENTRYPOINT ["/bin/bash", "-x", "/opt/app/dbupgrade/bin/docker_start.sh"]
\ No newline at end of file
diff --git a/cmso-database/etc/config/liquibase.properties b/cmso-database/etc/config/liquibase.properties
new file mode 100644 (file)
index 0000000..82c2f42
--- /dev/null
@@ -0,0 +1,60 @@
+###\r
+# Copyright &#194;© 2017-2018 AT&T Intellectual Property. \r
+# Modifications Copyright &#194;© 2018 IBM. \r
+#  \r
+# Licensed under the Apache License, Version 2.0 (the "License"); \r
+# you may not use this file except in compliance with the License. \r
+# You may obtain a copy of the License at \r
+#  \r
+#         http://www.apache.org/licenses/LICENSE-2.0 \r
+#  \r
+# Unless required by applicable law or agreed to in writing, software \r
+# distributed under the License is distributed on an "AS IS" BASIS, \r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \r
+# See the License for the specific language governing permissions and \r
+# limitations under the License. \r
+#  \r
+#  \r
+# Unless otherwise specified, all documentation contained herein is licensed \r
+# under the Creative Commons License, Attribution 4.0 Intl. (the &#195;¢&#226;?&#172;&#197;"License&#195;¢&#226;?&#172;&#157;); \r
+# you may not use this documentation except in compliance with the License. \r
+# You may obtain a copy of the License at \r
+#  \r
+#         https://creativecommons.org/licenses/by/4.0/ \r
+#  \r
+# Unless required by applicable law or agreed to in writing, documentation \r
+# distributed under the License is distributed on an "AS IS" BASIS, \r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \r
+# See the License for the specific language governing permissions and \r
+# limitations under the License.\r
+###\r
+\r
+#spring.datasource.url=jdbc:mysql://localhost:3306/cmso?createDatabaseIfNotExist=true\r
+#spring.datasource.driver-class-name=com.mysql.jdbc.Driver\r
+#spring.datasource.username=root\r
+#spring.datasource.password=root\r
+#\r
+#spring.datasource.url=jdbc:mariadb://localhost:3306/calendar?createDatabaseIfNotExist=true\r
+#spring.datasource.driver-class-name=org.mariadb.jdbc.Driver\r
+#spring.datasource.username=root\r
+#spring.datasource.password=root\r
+\r
+spring.datasource.initialize=false\r
+spring.datasource.tomcat.max-wait=10000\r
+spring.datasource.tomcat.initialSize=5\r
+spring.datasource.tomcat.max-active=25\r
+spring.datasource.tomcat.test-on-borrow=true\r
+\r
+\r
+#changeLogFile=calendar-liquibase-changeLog.xml\r
+changeLogFile=cmso-liquibase-changeLog.xml\r
+\r
+\r
+#spring.main.web-environment=false\r
+#outputChangeLogFile=src/main/resources/cmso-output-changelog.xml\r
+#url=jdbc:mariadb://localhost:3306/calendar\r
+#url=jdbc:mysql://localhost:3306/cmso\r
+#username=root\r
+#password=root\r
+#driver=org.mariadb.jdbc.Driver\r
+#driver=com.mysql.jdbc.Driver\r
diff --git a/cmso-database/pom.xml b/cmso-database/pom.xml
new file mode 100644 (file)
index 0000000..f5850f4
--- /dev/null
@@ -0,0 +1,122 @@
+<!--\r
+  Copyright © 2017-2018 AT&T Intellectual Property.\r
+  Modifications Copyright © 2018 IBM.\r
+  \r
+  Licensed under the Apache License, Version 2.0 (the "License");\r
+  you may not use this file except in compliance with the License.\r
+  You may obtain a copy of the License at\r
+  \r
+          http://www.apache.org/licenses/LICENSE-2.0\r
+  \r
+  Unless required by applicable law or agreed to in writing, software\r
+  distributed under the License is distributed on an "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  See the License for the specific language governing permissions and\r
+  limitations under the License.\r
+  \r
+  \r
+  Unless otherwise specified, all documentation contained herein is licensed\r
+  under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
+  you may not use this documentation except in compliance with the License.\r
+  You may obtain a copy of the License at\r
+  \r
+          https://creativecommons.org/licenses/by/4.0/\r
+  \r
+  Unless required by applicable law or agreed to in writing, documentation\r
+  distributed under the License is distributed on an "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  See the License for the specific language governing permissions and\r
+  limitations under the License.\r
+-->\r
+\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+       <modelVersion>4.0.0</modelVersion>\r
+\r
+       <parent>\r
+               <groupId>org.onap.oparent</groupId>\r
+               <artifactId>oparent</artifactId>\r
+               <version>1.2.0</version>\r
+       </parent>\r
+\r
+       <groupId>com.onap.optf</groupId>\r
+       <artifactId>liquibase</artifactId>\r
+       <version>0.1.0-SNAPSHOT</version>\r
+\r
+       <name>liquibase</name>\r
+       <description>Liquibase project for Spring Boot</description>\r
+\r
+       <properties>\r
+               <service.name>liquibase</service.name>\r
+               <release-tag>Casablanca</release-tag>\r
+               <name.space>org.onap.optf</name.space>\r
+               <serviceArtifactName>liquibase</serviceArtifactName>\r
+\r
+               <java.version>1.8</java.version>\r
+               <spring.version>5.0.8.RELEASE</spring.version>\r
+               <spring.boot.version>2.0.4.RELEASE</spring.boot.version>\r
+\r
+               <maven.compiler.target>1.8</maven.compiler.target>\r
+               <maven.compiler.source>1.8</maven.compiler.source>\r
+               <build.number>${maven.build.timestamp}</build.number>\r
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
+               <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>\r
+               <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>\r
+       </properties>\r
+\r
+       <dependencyManagement>\r
+               <dependencies>\r
+                       <!-- Spring boot -->\r
+                       <dependency>\r
+                               <groupId>org.springframework.boot</groupId>\r
+                               <artifactId>spring-boot-dependencies</artifactId>\r
+                               <version>${spring.boot.version}</version>\r
+                               <type>pom</type>\r
+                               <scope>import</scope>\r
+                       </dependency>\r
+               </dependencies>\r
+       </dependencyManagement>\r
+\r
+       <dependencies>\r
+               <dependency>\r
+                       <groupId>org.springframework.boot</groupId>\r
+                       <artifactId>spring-boot-starter-test</artifactId>\r
+                       <scope>test</scope>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>org.springframework.boot</groupId>\r
+                       <artifactId>spring-boot-starter-jdbc</artifactId>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>org.liquibase</groupId>\r
+                       <artifactId>liquibase-core</artifactId>\r
+                       </dependency>\r
+               <dependency>\r
+                       <groupId>mysql</groupId>\r
+                       <artifactId>mysql-connector-java</artifactId>\r
+               </dependency>\r
+               <dependency>\r
+                       <groupId>org.mariadb.jdbc</groupId>\r
+                       <artifactId>mariadb-java-client</artifactId>\r
+               </dependency>\r
+       </dependencies>\r
+\r
+       <build>\r
+               <plugins>\r
+                       <plugin>\r
+                               <groupId>org.springframework.boot</groupId>\r
+                               <artifactId>spring-boot-maven-plugin</artifactId>\r
+                               <version>2.0.4.RELEASE</version>\r
+                       </plugin>\r
+                       <plugin>\r
+                               <groupId>org.liquibase</groupId>\r
+                               <artifactId>liquibase-maven-plugin</artifactId>\r
+                               <version>3.5.5</version>\r
+                               <configuration>\r
+                                       <propertyFile>etc/config/liquibase.properties</propertyFile>\r
+                               </configuration>\r
+                       </plugin>\r
+               </plugins>\r
+               <finalName>docker-liquibase</finalName>\r
+       </build>\r
+</project>\r
diff --git a/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseApplication.java b/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseApplication.java
new file mode 100644 (file)
index 0000000..e3a581d
--- /dev/null
@@ -0,0 +1,47 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *         http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * \r
+ * Unless otherwise specified, all documentation contained herein is licensed\r
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
+ * you may not use this documentation except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *         https://creativecommons.org/licenses/by/4.0/\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, documentation\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+*/\r
+\r
+package org.onap.optf.cmso.liquibase;\r
+\r
+import org.springframework.boot.SpringApplication;\r
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;\r
+import org.springframework.boot.autoconfigure.SpringBootApplication;\r
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;\r
+import org.springframework.context.annotation.ComponentScan;\r
+\r
+@SpringBootApplication\r
+@ComponentScan(basePackages = "org.onap.optf.cmso.liquibase")\r
+public class LiquibaseApplication {\r
+\r
+    public static void main(String[] args) {\r
+        SpringApplication.run(LiquibaseApplication.class, args);\r
+    }\r
+}\r
diff --git a/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseData.java b/cmso-database/src/main/java/org/onap/optf/cmso/liquibase/LiquibaseData.java
new file mode 100644 (file)
index 0000000..842c70c
--- /dev/null
@@ -0,0 +1,77 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *         http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * \r
+ * Unless otherwise specified, all documentation contained herein is licensed\r
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
+ * you may not use this documentation except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *         https://creativecommons.org/licenses/by/4.0/\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, documentation\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+*/\r
+\r
+package org.onap.optf.cmso.liquibase;\r
+\r
+import javax.sql.DataSource;\r
+import org.springframework.beans.factory.annotation.Value;\r
+import org.springframework.boot.context.properties.ConfigurationProperties;\r
+import org.springframework.boot.jdbc.DataSourceBuilder;\r
+import org.springframework.context.annotation.Bean;\r
+import org.springframework.context.annotation.Configuration;\r
+import org.springframework.stereotype.Component;\r
+import liquibase.integration.spring.SpringLiquibase;\r
+\r
+/*\r
+ * Make sure following exceptions before build:\r
+ * Build errors\r
+ * java.net.ConnectException: Connection refused: connect (DB Connection)\r
+ * Make sure SQL files syntax are correct\r
+ * Always place new SQL files in src\main\resources\dbchangelog folder\r
+ * Please dont delete previous scripts\r
+ * Make sure to follow naming convention for SQL file (1806-cmso-v2-schema.sql)\r
+ * Please make sure to give author name and id for new SQL scripts (eg: changeSet author="bg4702"\r
+ * id="unique id")\r
+ ** IMPORTANT: Always do testing in local before pushing changes to Env's**\r
+ */\r
+\r
+@Component\r
+@Configuration\r
+public class LiquibaseData {\r
+\r
+    @Value("${changeLogFile}")\r
+    private String changeLogFile;\r
+\r
+    @Bean\r
+    public SpringLiquibase liquibase() {\r
+        SpringLiquibase liquibase = new SpringLiquibase();\r
+        liquibase.setDataSource(dataSource());\r
+        liquibase.setChangeLog("classpath:" + changeLogFile);\r
+        return liquibase;\r
+    }\r
+\r
+    @Bean\r
+    @ConfigurationProperties(prefix = "spring.datasource")\r
+    public DataSource dataSource() {\r
+        return DataSourceBuilder.create().build();\r
+    }\r
+\r
+}\r
diff --git a/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1-schema.sql b/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1-schema.sql
new file mode 100644 (file)
index 0000000..4a99994
--- /dev/null
@@ -0,0 +1,220 @@
+
+CREATE DATABASE IF NOT EXISTS CMSCHEDULER;
+USE CMSCHEDULER;
+
+CREATE TABLE IF NOT EXISTS DOMAINS (
+    domain VARCHAR(256) NOT NULL,
+    CONSTRAINT PK_DOMAINS PRIMARY KEY (domain)
+)  ENGINE=INNODB;
+
+CREATE UNIQUE INDEX DOMAIN_UNIQUE ON DOMAINS (domain ASC);
+
+
+-- -----------------------------------------------------
+-- Table SCHEDULES
+-- -----------------------------------------------------
+
+CREATE TABLE IF NOT EXISTS SCHEDULES (
+    id INT NOT NULL AUTO_INCREMENT,
+    domain VARCHAR(256) NOT NULL,
+    schedule_id VARCHAR(256) NULL,
+    schedule_name VARCHAR(256) NULL,
+    user_id VARCHAR(45) NULL,
+    status VARCHAR(45) NOT NULL,
+    create_date_time BIGINT NULL,
+    schedule_info MEDIUMTEXT NOT NULL,
+    schedule MEDIUMTEXT NULL,
+    optimizer_status VARCHAR(45) NULL,
+    optimizer_message MEDIUMTEXT NULL,
+    optimizer_date_time BIGINT NULL,
+    optimizer_return_date_time BIGINT NULL,
+    optimizer_attempts_to_schedule INT NOT NULL DEFAULT 0,
+    optimizer_transaction_id VARCHAR(128) NULL,
+    delete_date_time BIGINT NULL,
+    CONSTRAINT PK_SCHEDULES PRIMARY KEY (id),
+    CONSTRAINT FK_SCHEDULES_DOMAIN FOREIGN KEY (domain)
+        REFERENCES DOMAINS (domain)
+        ON DELETE NO ACTION ON UPDATE CASCADE
+)  ENGINE=INNODB;
+CREATE UNIQUE INDEX SCHEDULE_KEY ON SCHEDULES (domain ASC, schedule_id ASC);
+
+CREATE UNIQUE INDEX OPTIMIZER_TRANSACTION_ID_UNIQUE ON SCHEDULES (optimizer_transaction_id ASC);
+
+
+-- -----------------------------------------------------
+-- Table SCHEDULE_EVENTS
+-- -----------------------------------------------------
+CREATE TABLE IF NOT EXISTS SCHEDULE_EVENTS (
+    id INT(11) NOT NULL AUTO_INCREMENT,
+    schedules_id INT(11) NOT NULL,
+    event_time BIGINT(20) NOT NULL,
+    reminder_time BIGINT(20) NOT NULL,
+    domain VARCHAR(45) NULL DEFAULT NULL,
+    event_text MEDIUMTEXT NULL DEFAULT NULL,
+    status VARCHAR(45) NULL DEFAULT NULL,
+    CONSTRAINT PK_SCHEDULE_EVENTS PRIMARY KEY (id),
+    CONSTRAINT FK_SCHEDULE_EVENTS_SCHEDULES FOREIGN KEY (schedules_id)
+        REFERENCES SCHEDULES (id)
+        ON DELETE NO ACTION ON UPDATE NO ACTION
+)  ENGINE=INNODB;
+
+CREATE INDEX FK_SCHEDULE_EVENTS_SCHEDULES_IDX ON SCHEDULE_EVENTS (schedules_id ASC);
+
+CREATE INDEX SEQ_SVENTS ON SCHEDULE_EVENTS (reminder_time ASC);
+
+
+
+-- -----------------------------------------------------
+-- Table DOMAIN_DATA
+-- -----------------------------------------------------
+
+CREATE TABLE IF NOT EXISTS DOMAIN_DATA (
+    id INT NOT NULL AUTO_INCREMENT,
+    schedules_id INT NOT NULL,
+    name VARCHAR(128) NULL,
+    value MEDIUMTEXT NULL,
+    CONSTRAINT PK_DOMAIN_DATA PRIMARY KEY (id),
+    CONSTRAINT FK_DOMAIN_DATA_SCHEDULES FOREIGN KEY (schedules_id)
+        REFERENCES SCHEDULES (id)
+        ON DELETE NO ACTION ON UPDATE NO ACTION
+)  ENGINE=INNODB;
+
+CREATE UNIQUE INDEX ID_UNIQUE ON DOMAIN_DATA (id ASC);
+
+CREATE INDEX FK_DOMAIN_DATA_SCHEDULES_IDX ON DOMAIN_DATA (schedules_id ASC);
+
+
+-- -----------------------------------------------------
+-- Table APPROVAL_TYPES
+-- -----------------------------------------------------
+
+CREATE TABLE IF NOT EXISTS APPROVAL_TYPES (
+    id INT NOT NULL AUTO_INCREMENT,
+    domain VARCHAR(256) NOT NULL,
+    approval_type VARCHAR(45) NOT NULL,
+    approval_count INT NOT NULL DEFAULT 1,
+    CONSTRAINT PK_APPROVAL_TYPES PRIMARY KEY (id),
+    CONSTRAINT FK_APPROVAL_TYPES_DOMAIN FOREIGN KEY (domain)
+        REFERENCES DOMAINS (domain)
+        ON DELETE NO ACTION ON UPDATE CASCADE
+)  ENGINE=INNODB; 
+CREATE INDEX FK_DOMAIN_IDX ON APPROVAL_TYPES (domain ASC);
+
+
+-- -----------------------------------------------------
+-- Table SCHEDULE_APPROVALS
+-- -----------------------------------------------------
+
+CREATE TABLE IF NOT EXISTS SCHEDULE_APPROVALS (
+    id INT NOT NULL AUTO_INCREMENT,
+    schedules_id INT NOT NULL,
+    user_id VARCHAR(45) NOT NULL,
+    approval_type_id INT NOT NULL,
+    status VARCHAR(45) NOT NULL DEFAULT 'Pending Approval',
+    approval_date_time BIGINT NULL,
+    CONSTRAINT PK_SCHEDULE_APPROVALS PRIMARY KEY (id),
+    CONSTRAINT FK_SCHEDULE_APPROVALS_SCHEDULES FOREIGN KEY (schedules_id)
+        REFERENCES SCHEDULES (id)
+        ON DELETE NO ACTION ON UPDATE NO ACTION,
+    CONSTRAINT FK_SCHEDULE_APPROVALS_APPROVAL_TYPES FOREIGN KEY (approval_type_id)
+        REFERENCES APPROVAL_TYPES (id)
+        ON DELETE NO ACTION ON UPDATE NO ACTION
+)  ENGINE=INNODB;
+
+CREATE INDEX FK_SCHEDULE_APPROVALS_SCHEDULES_IDX ON SCHEDULE_APPROVALS (schedules_id ASC);
+
+CREATE INDEX FK_APPROVAL_TYPES_IDX ON SCHEDULE_APPROVALS (approval_type_id ASC);
+
+
+-- -----------------------------------------------------
+-- Table CHANGE_MANAGEMENT_GROUPS
+-- -----------------------------------------------------
+
+CREATE TABLE IF NOT EXISTS CHANGE_MANAGEMENT_GROUPS (
+    id INT NOT NULL AUTO_INCREMENT,
+    group_id VARCHAR(45) NULL,
+    schedules_id INT NULL,
+    start_time BIGINT NULL,
+    finish_time BIGINT NULL,
+    last_instance_start_time BIGINT NULL,
+    normal_duration_in_secs INT NULL,
+    additional_duration_in_secs INT NULL,
+    concurrency_limit INT NULL,
+    policy_id VARCHAR(256) NULL,
+    CONSTRAINT PK_CHANGE_MANAGEMENT_GROUPS PRIMARY KEY (id),
+    CONSTRAINT FK_CHANGE_MANAGEMENT_GROUPS_SCHEDULES FOREIGN KEY (schedules_id)
+        REFERENCES SCHEDULES (id)
+        ON DELETE NO ACTION ON UPDATE NO ACTION
+)  ENGINE=INNODB;
+
+CREATE INDEX FK_SCHEDULES_IDX ON CHANGE_MANAGEMENT_GROUPS (schedules_id ASC);
+
+CREATE UNIQUE INDEX CHANGE_MANAGEMENT_GROUP_ID_UNIQUE ON CHANGE_MANAGEMENT_GROUPS (schedules_id ASC, group_id ASC);
+
+
+-- -----------------------------------------------------
+-- Table CHANGE_MANAGEMENT_SCHEDULES
+-- -----------------------------------------------------
+
+CREATE TABLE IF NOT EXISTS CHANGE_MANAGEMENT_SCHEDULES (
+    id INT NOT NULL AUTO_INCREMENT,
+    change_management_groups_id INT NULL,
+    vnf_name VARCHAR(256) NOT NULL,
+    vnf_id VARCHAR(256) NULL,
+    status VARCHAR(45) NOT NULL,
+    start_time BIGINT NULL,
+    finish_time BIGINT NULL,
+    mso_request_id VARCHAR(45) NULL,
+    mso_status VARCHAR(45) NULL,
+    mso_message MEDIUMTEXT NULL,
+    mso_time BIGINT NULL,
+    dispatcher_instance VARCHAR(128) NULL,
+    dispatch_time BIGINT NULL,
+    execution_completed_time BIGINT NULL,
+    status_message MEDIUMTEXT NULL,
+    tm_change_id VARCHAR(15) NULL,
+    tm_approval_status VARCHAR(45) NULL,
+    tm_status VARCHAR(45) NULL,
+    CONSTRAINT PK_CHANGE_MANAGEMENT_SCHEDULES PRIMARY KEY (id),
+    CONSTRAINT FK_CHANGE_MANAGEMENT_SCHEDULES_CHANGE_MANAGEMENT_GROUP FOREIGN KEY (change_management_groups_id)
+        REFERENCES CHANGE_MANAGEMENT_GROUPS (id)
+        ON DELETE NO ACTION ON UPDATE NO ACTION
+)  ENGINE=INNODB;
+
+CREATE INDEX FK_CHANGE_MANAGEMENT_GROUP_CHANGE_MANAGEMENT_SCHEDULES_IDX ON CHANGE_MANAGEMENT_SCHEDULES (change_management_groups_id ASC);
+
+CREATE UNIQUE INDEX CHANGE_MANAGEMENT_SCHEDULES_VNF_NAME_UNIQUE ON CHANGE_MANAGEMENT_SCHEDULES (change_management_groups_id ASC, vnf_name ASC);
+
+
+-- -----------------------------------------------------
+-- Table CHANGE_MANAGEMENT_CHANGE_WINDOWS
+-- -----------------------------------------------------
+
+CREATE TABLE IF NOT EXISTS CHANGE_MANAGEMENT_CHANGE_WINDOWS (
+    id INT NOT NULL AUTO_INCREMENT,
+    change_management_groups_id INT NOT NULL,
+    start_time BIGINT NULL,
+    finish_time BIGINT NULL,
+    CONSTRAINT PK_CHANGE_MANAGEMENT_CHANGE_WINDOWS PRIMARY KEY (id),
+    CONSTRAINT FK_CHANGE_WINDOWS_CHANGE_MANAGEMENT_GROUPS1 FOREIGN KEY (change_management_groups_id)
+        REFERENCES CHANGE_MANAGEMENT_GROUPS (id)
+        ON DELETE NO ACTION ON UPDATE NO ACTION
+)  ENGINE=INNODB;
+
+CREATE INDEX FK_CHANGE_WINDOWS_CHANGE_MANAGEMENT_GROUPS1_IDX on CHANGE_MANAGEMENT_CHANGE_WINDOWS (change_management_groups_id ASC);
+
+
+
+
+-- comment SQL_SAFE_UPDATES code in dev setup (testing)
+-- uncomment in IT, IST, E2E Env's 
+SET SQL_SAFE_UPDATES = 0;
+
+DELETE FROM DOMAINS;
+
+INSERT INTO DOMAINS (`domain`) VALUES ('ChangeManagement');
+
+
+DELETE FROM APPROVAL_TYPES;
+
+INSERT INTO APPROVAL_TYPES (`domain`, `approval_type`, `approval_count`) VALUES ('ChangeManagement', 'Tier 2', '1');
\ No newline at end of file
diff --git a/cmso-database/src/main/resources/cmso-liquibase-changeLog.xml b/cmso-database/src/main/resources/cmso-liquibase-changeLog.xml
new file mode 100644 (file)
index 0000000..0bc23c1
--- /dev/null
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>\r
+<!--\r
+  Copyright © 2017-2018 AT&T Intellectual Property.\r
+  Modifications Copyright © 2018 IBM.\r
+  \r
+  Licensed under the Apache License, Version 2.0 (the "License");\r
+  you may not use this file except in compliance with the License.\r
+  You may obtain a copy of the License at\r
+  \r
+          http://www.apache.org/licenses/LICENSE-2.0\r
+  \r
+  Unless required by applicable law or agreed to in writing, software\r
+  distributed under the License is distributed on an "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  See the License for the specific language governing permissions and\r
+  limitations under the License.\r
+  \r
+  \r
+  Unless otherwise specified, all documentation contained herein is licensed\r
+  under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
+  you may not use this documentation except in compliance with the License.\r
+  You may obtain a copy of the License at\r
+  \r
+          https://creativecommons.org/licenses/by/4.0/\r
+  \r
+  Unless required by applicable law or agreed to in writing, documentation\r
+  distributed under the License is distributed on an "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  See the License for the specific language governing permissions and\r
+  limitations under the License.\r
+-->\r
+\r
+<databaseChangeLog\r
+       xmlns="http://www.liquibase.org/xml/ns/dbchangelog"\r
+       xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"\r
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">\r
+\r
+       <changeSet author="ATT" id="cmsched-v1-schema1">\r
+               <preConditions onFail="MARK_RAN">\r
+                       <not>\r
+                               <tableExists schemaName="cmso" tableName="schedules" />\r
+                       </not>\r
+               </preConditions>\r
+               <sqlFile path="cmso-dbchangelog/onap-cmso-v1-schema.sql" />\r
+       </changeSet>\r
+\r
+</databaseChangeLog>\r
diff --git a/cmso-database/src/test/java/org/onap/optf/cmso/liquibase/LiquibaseApplicationTests.java b/cmso-database/src/test/java/org/onap/optf/cmso/liquibase/LiquibaseApplicationTests.java
new file mode 100644 (file)
index 0000000..f63701e
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright © 2017-2018 AT&T Intellectual Property.\r
+ * Modifications Copyright © 2018 IBM.\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *         http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ * \r
+ * Unless otherwise specified, all documentation contained herein is licensed\r
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");\r
+ * you may not use this documentation except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *         https://creativecommons.org/licenses/by/4.0/\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, documentation\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+*/\r
+\r
+package org.onap.optf.cmso.liquibase;\r
+\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;\r
+import org.springframework.boot.test.context.SpringBootTest;\r
+import org.springframework.test.context.ActiveProfiles;\r
+import org.springframework.test.context.ContextConfiguration;\r
+import org.springframework.test.context.junit4.SpringRunner;\r
+\r
+@RunWith(SpringRunner.class)\r
+@ContextConfiguration(initializers = ConfigFileApplicationContextInitializer.class)\r
+@ActiveProfiles("test")\r
+// @SpringBootTest\r
+public class LiquibaseApplicationTests {\r
+\r
+    @Test\r
+    public void contextLoads() {}\r
+\r
+}\r
diff --git a/cmso-database/src/test/resources/application-test.properties b/cmso-database/src/test/resources/application-test.properties
new file mode 100644 (file)
index 0000000..e6d690b
--- /dev/null
@@ -0,0 +1,36 @@
+###\r
+# Copyright &#194;© 2017-2018 AT&T Intellectual Property. \r
+# Modifications Copyright &#194;© 2018 IBM. \r
+#  \r
+# Licensed under the Apache License, Version 2.0 (the "License"); \r
+# you may not use this file except in compliance with the License. \r
+# You may obtain a copy of the License at \r
+#  \r
+#         http://www.apache.org/licenses/LICENSE-2.0 \r
+#  \r
+# Unless required by applicable law or agreed to in writing, software \r
+# distributed under the License is distributed on an "AS IS" BASIS, \r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \r
+# See the License for the specific language governing permissions and \r
+# limitations under the License. \r
+#  \r
+#  \r
+# Unless otherwise specified, all documentation contained herein is licensed \r
+# under the Creative Commons License, Attribution 4.0 Intl. (the &#195;¢&#226;?&#172;&#197;"License&#195;¢&#226;?&#172;&#157;); \r
+# you may not use this documentation except in compliance with the License. \r
+# You may obtain a copy of the License at \r
+#  \r
+#         https://creativecommons.org/licenses/by/4.0/ \r
+#  \r
+# Unless required by applicable law or agreed to in writing, documentation \r
+# distributed under the License is distributed on an "AS IS" BASIS, \r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \r
+# See the License for the specific language governing permissions and \r
+# limitations under the License.\r
+###\r
+\r
+spring.datasource.url=jdbc:mariadb://localhost:3306/cmso?createDatabaseIfNotExist=true\r
+spring.datasource.driver-class-name=org.mariadb.jdbc.Driver\r
+spring.datasource.username=root\r
+spring.datasource.password=root\r
+changeLogFile=cmso-liquibase-changeLog.xml\r