Created
April 22, 2020 00:34
-
-
Save pbdeuchler/79efb5ebc053f891ac6c67051dc6620e to your computer and use it in GitHub Desktop.
Bootstraps a postgres server with a database and read/write user
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
#!/bin/bash -eu | |
# Run command: PROJECT_NAME=test RW_PASSWORD=test HOSTNAME=127.0.0.1 ./psql_bootstrap | |
psql -h $HOSTNAME --username=postgres -c 'DROP DATABASE IF EXISTS '"${PROJECT_NAME}"';' | |
psql -h $HOSTNAME --username=postgres -c 'DROP USER IF EXISTS '"${PROJECT_NAME}"'_rw;' | |
psql -h $HOSTNAME --username=postgres -c 'CREATE DATABASE '"${PROJECT_NAME}"';' | |
psql -h $HOSTNAME --username=postgres -c 'CREATE USER '"${PROJECT_NAME}"'_rw WITH PASSWORD '"'${RW_PASSWORD}'"';' | |
psql -h $HOSTNAME --username=postgres -c 'GRANT ALL PRIVILEGES ON DATABASE '"${PROJECT_NAME}"' TO '"${PROJECT_NAME}"'_rw;' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment