Merge "[UUI] Service Mesh Compliance for UUI"
[oom.git] / kubernetes / vid / resources / config / db_cmd.sh
1 #!/bin/sh
2 {{/*
3 # Copyright © 2018 AT&T
4 # Copyright © 2020 Aarna Networks
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 */}}
18
19 DB={{index .Values "mariadb-galera" "db" "name" | upper }}
20 eval "MYSQL_USER=\$MYSQL_USER_${DB}"
21 eval "MYSQL_PASSWORD=\$MYSQL_PASSWORD_${DB}"
22
23 #echo "Going to run mysql ${DB} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${DB_HOST} -P${DB_PORT} ..."
24 mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${DB_HOST} -P${DB_PORT} <<'EOD'
25 CREATE TABLE IF NOT EXISTS `{{index .Values "mariadb-galera" "db" "name" }}`.`schema_info` (
26 `SCHEMA_ID` VARCHAR(25) NOT NULL,
27 `SCHEMA_DESC` VARCHAR(75) NOT NULL,
28 `DATASOURCE_TYPE` VARCHAR(100) NULL DEFAULT NULL,
29 `CONNECTION_URL` VARCHAR(200) NOT NULL,
30 `USER_NAME` VARCHAR(45) NOT NULL,
31 `PASSWORD` VARCHAR(45) NULL DEFAULT NULL,
32 `DRIVER_CLASS` VARCHAR(100) NOT NULL,
33 `MIN_POOL_SIZE` INT(11) NOT NULL,
34 `MAX_POOL_SIZE` INT(11) NOT NULL,
35 `IDLE_CONNECTION_TEST_PERIOD` INT(11) NOT NULL)
36 ENGINE = InnoDB
37 DEFAULT CHARACTER SET = utf8;
38 EOD
39
40 if [ $? -ne 0 ];then
41         echo "ERROR: Failed to run cmd vid-pre-init.sql"
42         exit 1
43 else
44         echo "INFO: Database initialized successfully"
45 fi