apiVersion: v1
kind: ConfigMap
metadata:
  namespace: loraserverio
  name: init-config
data:
  001-init-loraserver_ns.sh: |
    #!/bin/bash
    set -e

    psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
        create role loraserver_ns with login password 'loraserver_ns';
        create database loraserver_ns with owner loraserver_ns;
    EOSQL

  002-init-loraserver_as.sh: |
    #!/bin/bash
    set -e

    psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL
        create role loraserver_as with login password 'loraserver_as';
        create database loraserver_as with owner loraserver_as;
    EOSQL
  003-loraserver_as_trgm.sh: |
    #!/bin/bash
    set -e

    psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname="loraserver_as" <<-EOSQL
        create extension pg_trgm;
    EOSQL
  004-loraserver_as_hstore.sh: |
    #!/bin/bash
    set -e

    psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname="loraserver_as" <<-EOSQL
        create extension hstore;
    EOSQL
