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 09:30:45 +02:00
# CREATE USER my_user PASSWORD my_password;
2018-06-14 22:39:19 +02:00
# CREATE DATABASE myshop_db;
2018-06-15 09:30:45 +02:00
# GRANT ALL PRIVILEGES ON DATABASE myshop_db TO my_user;
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 09:27:37 +02:00
# CREATE USER db1 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 09:27:37 +02:00
# CREATE USER db2 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 09:27:37 +02:00
# CREATE USER db3 PASSWORD db3;
2018-06-14 22:39:19 +02:00
# CREATE DATABASE db3;
# GRANT ALL PRIVILEGES ON DATABASE db3 TO db3;
# EOSQL