Update CLAMP mariadb version to 10.3.12

Update to new mariadb version for Dublin along with a few SQL updates.

Issue-ID: CLAMP-324
Change-Id: Ia0a095111332768af97d82f606d7c1048bfd812c
Signed-off-by: ChrisC <christophe.closset@intl.att.com>
diff --git a/kubernetes/clamp/charts/mariadb/resources/config/mariadb/docker-entrypoint-initdb.d/bulkload/clds-create-db-objects.sql b/kubernetes/clamp/charts/mariadb/resources/config/mariadb/docker-entrypoint-initdb.d/bulkload/clds-create-db-objects.sql
index 6f614a7..a6beca2 100644
--- a/kubernetes/clamp/charts/mariadb/resources/config/mariadb/docker-entrypoint-initdb.d/bulkload/clds-create-db-objects.sql
+++ b/kubernetes/clamp/charts/mariadb/resources/config/mariadb/docker-entrypoint-initdb.d/bulkload/clds-create-db-objects.sql
@@ -1,4 +1,4 @@
-/* Copyright © 2017 AT&T, Amdocs, Bell Canada
+/* Copyright © 2017-2019 AT&T, Amdocs, Bell Canada
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -122,14 +122,6 @@
   PRIMARY KEY (event_id)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
 
-CREATE TABLE clds_service_cache (
-  invariant_service_id VARCHAR(36) NOT NULL,
-  service_id VARCHAR(36) NULL,
-  timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-  object_data MEDIUMBLOB NULL,
-  PRIMARY KEY (invariant_service_id)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
-
 CREATE TABLE IF NOT EXISTS tosca_model (
   tosca_model_id VARCHAR(36) NOT NULL,
   tosca_model_name VARCHAR(80) NOT NULL,
diff --git a/kubernetes/clamp/charts/mariadb/resources/config/mariadb/docker-entrypoint-initdb.d/bulkload/create-tables.sql b/kubernetes/clamp/charts/mariadb/resources/config/mariadb/docker-entrypoint-initdb.d/bulkload/create-tables.sql
new file mode 100644
index 0000000..8e51f62
--- /dev/null
+++ b/kubernetes/clamp/charts/mariadb/resources/config/mariadb/docker-entrypoint-initdb.d/bulkload/create-tables.sql
@@ -0,0 +1,84 @@
+/* Copyright © 2019 AT&T
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*       http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+    create table hibernate_sequence (
+       next_val bigint
+    ) engine=InnoDB;
+
+    insert into hibernate_sequence values ( 1 );
+
+    create table loop_logs (
+       id bigint not null,
+        log_instant datetime(6) not null,
+        log_type varchar(255) not null,
+        message varchar(255) not null,
+        loop_id varchar(255) not null,
+        primary key (id)
+    ) engine=InnoDB;
+
+    create table loops (
+       name varchar(255) not null,
+        blueprint_yaml MEDIUMTEXT not null,
+        dcae_blueprint_id varchar(255),
+        dcae_deployment_id varchar(255),
+        dcae_deployment_status_url varchar(255),
+        global_properties_json json,
+        last_computed_state varchar(255) not null,
+        model_properties_json json,
+        svg_representation MEDIUMTEXT,
+        primary key (name)
+    ) engine=InnoDB;
+
+    create table loops_microservicepolicies (
+       loop_id varchar(255) not null,
+        microservicepolicy_id varchar(255) not null,
+        primary key (loop_id, microservicepolicy_id)
+    ) engine=InnoDB;
+
+    create table micro_service_policies (
+       name varchar(255) not null,
+        json_representation json not null,
+        model_type varchar(255) not null,
+        policy_tosca MEDIUMTEXT not null,
+        properties json,
+        shared bit not null,
+        primary key (name)
+    ) engine=InnoDB;
+
+    create table operational_policies (
+       name varchar(255) not null,
+        configurations_json json,
+        loop_id varchar(255) not null,
+        primary key (name)
+    ) engine=InnoDB;
+
+    alter table loop_logs
+       add constraint FK1j0cda46aickcaoxqoo34khg2
+       foreign key (loop_id)
+       references loops (name);
+
+    alter table loops_microservicepolicies
+       add constraint FKem7tp1cdlpwe28av7ef91j1yl
+       foreign key (microservicepolicy_id)
+       references micro_service_policies (name);
+
+    alter table loops_microservicepolicies
+       add constraint FKsvx91jekgdkfh34iaxtjfgebt
+       foreign key (loop_id)
+       references loops (name);
+
+    alter table operational_policies
+       add constraint FK1ddoggk9ni2bnqighv6ecmuwu
+       foreign key (loop_id)
+       references loops (name);
diff --git a/kubernetes/clamp/charts/mariadb/resources/config/mariadb/docker-entrypoint-initdb.d/load-sql-files-tests-automation.sh b/kubernetes/clamp/charts/mariadb/resources/config/mariadb/docker-entrypoint-initdb.d/load-sql-files-tests-automation.sh
old mode 100644
new mode 100755
index 1c8f3bf..0755826
--- a/kubernetes/clamp/charts/mariadb/resources/config/mariadb/docker-entrypoint-initdb.d/load-sql-files-tests-automation.sh
+++ b/kubernetes/clamp/charts/mariadb/resources/config/mariadb/docker-entrypoint-initdb.d/load-sql-files-tests-automation.sh
@@ -7,6 +7,7 @@
 # Copyright (C) 2017 AT&T Intellectual Property. All rights
 #                             reserved.
 # Modifications Copyright © 2018 Amdocs,Bell Canada
+# Modifications Copyright © 2019 AT&T
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -25,5 +26,8 @@
 ###
 
 cd /docker-entrypoint-initdb.d/bulkload
+### Keep previous DB for now (SOON DEPRECATED)
 mysql -uroot -p$MYSQL_ROOT_PASSWORD -f < clds-create-db-objects.sql
 mysql -uroot -p$MYSQL_ROOT_PASSWORD -f < clds-stored-procedures.sql
+## New model creation
+mysql -uroot -p$MYSQL_ROOT_PASSWORD -f cldsdb4 < create-tables.sql
diff --git a/kubernetes/clamp/charts/mariadb/values.yaml b/kubernetes/clamp/charts/mariadb/values.yaml
index 13d1971..5f31c79 100644
--- a/kubernetes/clamp/charts/mariadb/values.yaml
+++ b/kubernetes/clamp/charts/mariadb/values.yaml
@@ -1,5 +1,5 @@
 # Copyright © 2017 Amdocs, Bell Canada
-# Modifications Copyright © 2018 AT&T
+# Modifications Copyright © 2018-2019 AT&T
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@
 
 # application image
 repository: nexus3.onap.org:10001
-image: mariadb:10.1.11
+image: mariadb:10.3.12
 pullPolicy: Always
 flavor: small