Skip to content

Instantly share code, notes, and snippets.

@jship
Created April 22, 2022 13:52
Show Gist options
  • Save jship/6fd2a9ed64010af44da7e3fb3caa5202 to your computer and use it in GitHub Desktop.
Save jship/6fd2a9ed64010af44da7e3fb3caa5202 to your computer and use it in GitHub Desktop.
Gross script to whack all pg data and make a fresh DB
#!/usr/bin/env bash
set -o errexit
set -o pipefail
[[ "${DEBUG}" == 'true' ]] && set -o xtrace
brew services stop postgresql@12
rm -rf /usr/local/var/postgresql\@12/
initdb -E utf8 -U postgres /usr/local/var/postgresql\@12/
sleep 5
psql -v ON_ERROR_STOP=1 -U postgres <<-EOSQL
CREATE USER "foo" WITH PASSWORD 'foo';
CREATE DATABASE "foo";
GRANT ALL PRIVILEGES ON DATABASE "foo" TO "foo";
EOSQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment