Skip to content

Instantly share code, notes, and snippets.

@Apreche
Last active April 7, 2020 15:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Apreche/19495f6832534bfa45bd60835a233043 to your computer and use it in GitHub Desktop.
Save Apreche/19495f6832534bfa45bd60835a233043 to your computer and use it in GitHub Desktop.
Create a new PostgreSQL database and user for local development
#!/usr/bin/env bash
# Create a postgres database, user, and password for a local dev app
psql << EOF
CREATE DATABASE $1;
CREATE USER $1 WITH PASSWORD '$1';
ALTER ROLE $1 SET client_encoding to 'utf8';
ALTER ROLE $1 SET default_transaction_isolation TO 'read committed';
ALTER ROLE $1 SET timezone to 'UTC';
GRANT ALL PRIVILEGES on DATABASE $1 to $1;
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment