Use the POSTGRES_USER when running self hosting migrations

This commit is contained in:
Jackson Harper
2023-05-10 13:20:04 +08:00
parent aaaa1e6790
commit 0bdb4f8ac1

View File

@ -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"