From aaaa1e6790d47d740543d78f89d13acb0bcab48f Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 10 May 2023 11:56:53 +0800 Subject: [PATCH 1/2] Remove PG_USER from script, we will rely on POSTGRES_USER for this --- self-hosting/selfhost.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/self-hosting/selfhost.sh b/self-hosting/selfhost.sh index a950dd163..c27a22af1 100644 --- a/self-hosting/selfhost.sh +++ b/self-hosting/selfhost.sh @@ -1,16 +1,16 @@ #!/bin/sh echo "creating omnivore database with $(which psql)" -psql --host $PG_HOST -U $PG_USER -c "CREATE DATABASE omnivore;" +psql --host $PG_HOST -c "CREATE DATABASE omnivore;" echo "creating app_user" -psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "CREATE USER app_user WITH PASSWORD 'app_pass';" +psql --host $PG_HOST -d $PG_DB -c "CREATE USER app_user WITH PASSWORD 'app_pass';" echo "created app_user" echo "running migrations" yarn workspace @omnivore/db migrate -psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "GRANT omnivore_user TO app_user;" +psql --host $PG_HOST -d $PG_DB -c "GRANT omnivore_user TO app_user;" echo "granted omnivore_user to app_user" yarn workspace @omnivore/api start From 0bdb4f8ac1b457b1229386854992dd52f8e30f14 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 10 May 2023 13:20:04 +0800 Subject: [PATCH 2/2] Use the POSTGRES_USER when running self hosting migrations --- self-hosting/selfhost.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/self-hosting/selfhost.sh b/self-hosting/selfhost.sh index c27a22af1..c64b2b768 100644 --- a/self-hosting/selfhost.sh +++ b/self-hosting/selfhost.sh @@ -1,14 +1,14 @@ #!/bin/sh -echo "creating omnivore database with $(which psql)" +echo "creating omnivore database with $(which psql) and user: $POSTGRES_USER" psql --host $PG_HOST -c "CREATE DATABASE omnivore;" echo "creating app_user" -psql --host $PG_HOST -d $PG_DB -c "CREATE USER app_user WITH PASSWORD 'app_pass';" +psql --host $PG_HOST -d $PG_DB -c "CREATE USER app_user WITH ENCRYPTED PASSWORD '$PG_PASSWORD';" echo "created app_user" -echo "running migrations" -yarn workspace @omnivore/db migrate +echo "running migrations as $POSTGRES_USER" +PG_USER=$POSTGRES_USER PG_PASSWORD=$POSTGRES_PASSWORD yarn workspace @omnivore/db migrate psql --host $PG_HOST -d $PG_DB -c "GRANT omnivore_user TO app_user;" echo "granted omnivore_user to app_user"