Skip to content

Instantly share code, notes, and snippets.

@adamvaughan
Last active June 14, 2016 17:55
Show Gist options
  • Save adamvaughan/378cb5fa82d7378e184fe34e524c8bca to your computer and use it in GitHub Desktop.
Save adamvaughan/378cb5fa82d7378e184fe34e524c8bca to your computer and use it in GitHub Desktop.
DB Candy
function copydb --description 'Copy a remote database locally.'
dropdb (dbname $argv)_development
createdb (dbname $argv)_development
pg_dump -h (dbhost $argv) -U inside_track -d (dbname $argv) | psql -d (dbname $argv)_development -f -
end
function dbhost
echo (echo $argv-db | sed s/-staging-db/-db-staging/).ucoachapp.com
end
function dbname
echo (echo $argv | sed s/-staging//)
end
function pgr --description 'Connect to a remote PostgreSQL instance.'
psql -h (dbhost $argv) -U inside_track -d (dbname $argv)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment