This commit is contained in:
Peter Smit
2025-09-26 12:50:38 +02:00
parent 581a8dd635
commit 6ffa2aa4b4

View File

@@ -16,19 +16,19 @@ create_db_and_user() {
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
-- Create database -- Create database
CREATE DATABASE $($db_name); CREATE DATABASE "$db_name";
-- Create user with password -- Create user with password
CREATE USER $db_user WITH ENCRYPTED PASSWORD '$db_password'; CREATE USER $db_user WITH ENCRYPTED PASSWORD '$db_password';
-- Grant connection to the specific database only -- Grant connection to the specific database only
GRANT CONNECT ON DATABASE $($db_name) TO $db_user; GRANT CONNECT ON DATABASE "$db_name" TO $db_user;
-- Make user owner of the database -- Make user owner of the database
ALTER DATABASE $($db_name) OWNER TO $db_user; ALTER DATABASE "$db_name" OWNER TO $db_user;
-- Connect to the specific database to set schema permissions -- Connect to the specific database to set schema permissions
\c $($db_name) \c "$db_name"
-- Grant schema permissions -- Grant schema permissions
GRANT ALL ON SCHEMA public TO $db_user; GRANT ALL ON SCHEMA public TO $db_user;