-
-
Notifications
You must be signed in to change notification settings - Fork 885
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically manage database when running scripts/test.sh (#3389)
* Update .gitignore * Create start-dev-db.sh * Rename start-dev-db.sh to start_dev_db.sh * Update .gitignore * Update start_dev_db.sh * Update start_dev_db.sh * Update start_dev_db.sh * Update start_dev_db.sh * h * Update test.sh * Update start_dev_db.sh * made it work * Make test.sh work when run from scripts dir
- Loading branch information
1 parent
3159eed
commit 7d3894d
Showing
3 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# This script is meant to be run with `source` so it can set environment variables. | ||
|
||
export PGDATA="$PWD/dev_pgdata" | ||
export PGHOST=$PWD | ||
export LEMMY_DATABASE_URL="postgresql://lemmy:password@/lemmy?host=$PWD" | ||
|
||
# If cluster exists, stop the server and delete the cluster | ||
if [ -d $PGDATA ] | ||
then | ||
# Prevent `stop` from failing if server already stopped | ||
pg_ctl restart > /dev/null | ||
pg_ctl stop | ||
rm -rf $PGDATA | ||
fi | ||
|
||
# Create cluster | ||
initdb --username=postgres --auth=trust --no-instructions | ||
|
||
# Start server that only listens to socket in current directory | ||
pg_ctl start --options="-c listen_addresses= -c unix_socket_directories=$PWD" > /dev/null | ||
|
||
# Setup database | ||
psql -c "CREATE USER lemmy WITH PASSWORD 'password' SUPERUSER;" -U postgres | ||
psql -c "CREATE DATABASE lemmy WITH OWNER lemmy;" -U postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters