Skip to content

Commit 870e446

Browse files
committed
feat: Update script for running migrations
1 parent 628d188 commit 870e446

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

scripts/init_db.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,10 @@ if ! [ -x "$(command -v sqlx)" ]; then
1616
exit 1
1717
fi
1818

19-
# Check if a custom user has been set, otherwise default to 'postgres'
2019
DB_USER=${POSTGRES_USER:=postgres}
21-
# Check if a custom password has been set, otherwise default to 'password'
2220
DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
23-
# Check if a custom database name has been set, otherwise default to 'bibimbap'
2421
DB_NAME="${POSTGRES_DB:=bibimbap}"
25-
# Check if a custom port has been set, otherwise default to '5432'
2622
DB_PORT="${POSTGRES_PORT:=5432}"
27-
# Check if a custom host has been set, otherwise default to 'localhost'
2823
DB_HOST="${POSTGRES_HOST:=localhost}"
2924

3025
# Launch Postgres using Docker
@@ -43,8 +38,11 @@ until psql -h "${DB_HOST}" -U "${DB_USER}" -p "${DB_PORT}" -d "postgres" -c '\q'
4338
sleep 1
4439
done
4540

46-
>&2 echo "Postgres is up and running on port ${DB_PORT}!"
41+
>&2 echo "Postgres is up and running on port ${DB_PORT} - running migrations now!"
4742

4843
DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}
4944
export DATABASE_URL
5045
sqlx database create
46+
sqlx migrate run
47+
48+
>&2 echo "Postgres has been migrated, ready to go!"

0 commit comments

Comments
 (0)