blob: daa1f8b6ea8469279e081c526b41772bc5402745 [file] [log] [blame]
Mandeep Khinda561a91c2018-08-23 14:08:52 +00001#!/bin/sh
Jakub Latusekd9c241b2020-10-21 13:36:30 +02002{{/*
Mandeep Khinda561a91c2018-08-23 14:08:52 +00003# Copyright © 2018 AT&T
RPMishrae4ee7f12020-10-07 12:09:01 +05304# Copyright © 2020 Aarna Networks
Mandeep Khinda561a91c2018-08-23 14:08:52 +00005#
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.
Jakub Latusekd9c241b2020-10-21 13:36:30 +020017*/}}
Mandeep Khinda561a91c2018-08-23 14:08:52 +000018
Sylvain Desbureaux93a5b492020-11-27 11:07:42 +010019DB={{index .Values "mariadb-galera" "db" "name" | upper }}
RPMishrae4ee7f12020-10-07 12:09:01 +053020eval "MYSQL_USER=\$MYSQL_USER_${DB}"
21eval "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} ..."
24mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${DB_HOST} -P${DB_PORT} <<'EOD'
Sylvain Desbureaux93a5b492020-11-27 11:07:42 +010025CREATE TABLE IF NOT EXISTS `{{index .Values "mariadb-galera" "db" "name" }}`.`schema_info` (
RPMishrae4ee7f12020-10-07 12:09:01 +053026`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)
36ENGINE = InnoDB
37DEFAULT CHARACTER SET = utf8;
38EOD
39
Mandeep Khinda561a91c2018-08-23 14:08:52 +000040if [ $? -ne 0 ];then
RPMishrae4ee7f12020-10-07 12:09:01 +053041 echo "ERROR: Failed to run cmd vid-pre-init.sql"
Mandeep Khinda561a91c2018-08-23 14:08:52 +000042 exit 1
43else
44 echo "INFO: Database initialized successfully"
45fi