mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 02:35:14 +00:00
docker: init: 02-postgres.sh: allow DB user to create new DB (for tests)
This commit is contained in:
parent
7acc31ec97
commit
7e5be6094f
1 changed files with 2 additions and 1 deletions
|
|
@ -57,13 +57,14 @@ if [ -z "$(ls -A $POSTGRES_DIR)" ]; then
|
|||
echo "Creating PostgreSQL database..."
|
||||
su - postgres -c "createdb -p ${POSTGRES_PORT} ${POSTGRES_DB}"
|
||||
|
||||
# Create user, set ownership, and grant privileges
|
||||
# Create user, set ownership, and grant privileges, including privileges to create new databases
|
||||
echo "Creating PostgreSQL user..."
|
||||
su - postgres -c "psql -p ${POSTGRES_PORT} -d ${POSTGRES_DB}" <<EOF
|
||||
DO \$\$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '$POSTGRES_USER') THEN
|
||||
CREATE ROLE $POSTGRES_USER WITH LOGIN PASSWORD '$POSTGRES_PASSWORD';
|
||||
ALTER ROLE $POSTGRES_USER CREATEDB;
|
||||
END IF;
|
||||
END
|
||||
\$\$;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue