#!/bin/bash
set -e

psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_USER" <<-EOSQL
    CREATE DATABASE platform_manager_cache;
    GRANT ALL PRIVILEGES ON DATABASE platform_manager_cache TO polymatica;
    CREATE DATABASE platform_manager;
    GRANT ALL PRIVILEGES ON DATABASE platform_manager TO polymatica;
    CREATE DATABASE platform_dashboard;
    GRANT ALL PRIVILEGES ON DATABASE platform_dashboard TO polymatica;
    CREATE DATABASE platform_notifications;
    GRANT ALL PRIVILEGES ON DATABASE platform_notifications TO polymatica;
    CREATE DATABASE platform_logstash;
    GRANT ALL PRIVILEGES ON DATABASE platform_logstash TO polymatica;
    CREATE DATABASE platform_storage;
    GRANT ALL PRIVILEGES ON DATABASE platform_storage TO polymatica;

EOSQL
