############################################################################
# Copyright 2021 Huawei Technologies Co., Ltd.
# 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.
############################################################################


# pg secret
# pg init secret
---
apiVersion: v1
kind: Secret
metadata:
  name: meo-db-init-sql
  labels:
    app: meo-db-init-sql
type: Opaque
stringData:
  init.sql: |-
    CREATE USER inventory WITH PASSWORD '{{ .Values.mecm.postgres.inventoryDbPass }}' CREATEDB;
    CREATE DATABASE inventorydb WITH OWNER = inventory
                                     ENCODING = 'UTF8'
                                     LC_COLLATE = 'en_US.utf8'
                                     LC_CTYPE = 'en_US.utf8'
                                     TABLESPACE = pg_default
                                     CONNECTION LIMIT = -1;
    CREATE USER appo WITH PASSWORD '{{ .Values.mecm.postgres.appoDbPass }}' CREATEDB;
    CREATE DATABASE appodb WITH OWNER = appo
                                     ENCODING = 'UTF8'
                                     LC_COLLATE = 'en_US.utf8'
                                     LC_CTYPE = 'en_US.utf8'
                                     TABLESPACE = pg_default
                                     CONNECTION LIMIT = -1;
    CREATE USER apm WITH PASSWORD '{{ .Values.mecm.postgres.apmDbPass }}' CREATEDB;
    CREATE DATABASE apmdb WITH OWNER = apm
                                     ENCODING = 'UTF8'
                                     LC_COLLATE = 'en_US.utf8'
                                     LC_CTYPE = 'en_US.utf8'
                                     TABLESPACE = pg_default
                                     CONNECTION LIMIT = -1;    
    CREATE USER north WITH PASSWORD '{{ .Values.mecm.postgres.northDbPass }}' CREATEDB;
    CREATE DATABASE northdb WITH OWNER = north
                                     ENCODING = 'UTF8'
                                     LC_COLLATE = 'en_US.utf8'
                                     LC_CTYPE = 'en_US.utf8'
                                     TABLESPACE = pg_default
                                     CONNECTION LIMIT = -1;    

