-
-
Save mscoutermarsh/5278928 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env bash | |
# kill all connections to the postgres server | |
if [ -n "$1" ] ; then | |
where="where pg_stat_activity.datname = '$1'" | |
echo "killing all connections to database '$1'" | |
else | |
where="where pg_stat_activity.datname in (select datname from pg_database where datname != 'postgres')" | |
echo "killing all connections to database" | |
fi | |
cat <<-EOF | psql -U mhenrixon -d postgres | |
SELECT pg_terminate_backend(pg_stat_activity.pid) | |
FROM pg_stat_activity | |
${where} | |
EOF |
This file contains hidden or 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
alias mgd="RAILS_ENV=development bundle exec rake db:migrate" | |
alias mgt="RAILS_ENV=test bundle exec rake db:migrate" | |
alias mg="mgd && mgt" | |
alias mgtrace="$mgd --trace && $mgt --trace" | |
alias mgr="$mgd:redo && $mgt:redo" | |
alias mgrtrace="$mgd:redo --trace && $mgt:redo --trace" | |
alias rbd="RAILS_ENV=development bundle exec rake db:rollback" | |
alias rbt="RAILS_ENV=test bundle exec rake db:rollback" | |
alias rb="rbd && rbt" | |
alias fuckd="dropd && created && mgd && bundle exec rake db:seed" | |
alias fuckt="dropt && createt && mgt" | |
alias fuckdb="dropdb && createdb && mg && bundle exec rake db:seed" | |
alias dropd="~/pg_kill.sh && RAILS_ENV=development bundle exec rake db:drop" | |
alias dropt="~/pg_kill.sh && RAILS_ENV=test bundle exec rake db:drop" | |
alias dropdb="dropd && dropt" | |
alias createdb="~/pg_kill.sh && bundle exec rake db:create" | |
alias created="~/pg_kill.sh && RAILS_ENV=development bundle exec rake db:create" | |
alias createt="~/pg_kill.sh && RAILS_ENV=test bundle exec rake db:create" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment