Skip to content

Instantly share code, notes, and snippets.

@henrywoody
Last active September 17, 2020 01:12
Show Gist options
  • Save henrywoody/22c6df8b8562149fe4f7a7450f84ea7b to your computer and use it in GitHub Desktop.
Save henrywoody/22c6df8b8562149fe4f7a7450f84ea7b to your computer and use it in GitHub Desktop.
Postgres Database Setup
-- Requires the following environment variables:
-- - `DB_NAME`
-- - `DB_USER`
-- - `DB_PASS`
-- To run (in shell):
-- `psql postgres -h $DB_HOST -p $DB_PORT -f /path/to/setup-db.sql`
\set db_name `echo $DB_NAME`
\set db_user `echo $DB_USER`
\set db_pass `echo $DB_PASS`
CREATE DATABASE :db_name;
CREATE ROLE :db_user WITH LOGIN PASSWORD :'db_pass';
GRANT ALL PRIVILEGES ON DATABASE :db_name TO :db_user;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment