blackbirdchess-docker-dev/postgres/docker-entrypoint-initdb.d/createdb.sh.example

35 lines
1.2 KiB
Plaintext
Raw Normal View History

2018-06-14 22:39:19 +02:00
#!/bin/bash
#
# Copy createdb.sh.example to createdb.sh
# then uncomment then set database name and username to create you need databases
#
# example: .env POSTGRES_USER=appuser and need db name is myshop_db
#
# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
2018-06-15 17:37:27 +02:00
# CREATE USER myuser WITH PASSWORD 'mypassword';
2018-06-14 22:39:19 +02:00
# CREATE DATABASE myshop_db;
2018-06-15 17:27:28 +02:00
# GRANT ALL PRIVILEGES ON DATABASE myshop_db TO myuser;
2018-06-14 22:39:19 +02:00
# EOSQL
#
# this sh script will auto run when the postgres container starts and the $DATA_PATH_HOST/postgres not found.
#
set -e
# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
2018-06-15 17:37:27 +02:00
# CREATE USER db1 WITH PASSWORD 'db1';
2018-06-14 22:39:19 +02:00
# CREATE DATABASE db1;
# GRANT ALL PRIVILEGES ON DATABASE db1 TO db1;
# EOSQL
# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
2018-06-15 17:37:27 +02:00
# CREATE USER db2 WITH PASSWORD 'db2';
2018-06-14 22:39:19 +02:00
# CREATE DATABASE db2;
# GRANT ALL PRIVILEGES ON DATABASE db2 TO db2;
# EOSQL
# psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
2018-06-15 17:37:27 +02:00
# CREATE USER db3 WITH PASSWORD 'db3';
2018-06-14 22:39:19 +02:00
# CREATE DATABASE db3;
# GRANT ALL PRIVILEGES ON DATABASE db3 TO db3;
# EOSQL