Skip to content

Instantly share code, notes, and snippets.

@mulholio mulholio/db.sh
Created Feb 12, 2019

Embed
What would you like to do?
Update your development Rails database with the latest copy of your production Heroku database
output="$PWD/db.dump"
dropDB() {
# set db username (might not be $USER in your case)
local username="$USER"
local dbname="YOUR_DATABASE_NAME" # your sushi_app_development
rake db:drop DISABLE_DATABASE_ENVIRONMENT_CHECK=1
rake db:create
# you might need a password in here for your machine
pg_restore -h "localhost" --port "5432" -U "$username" --password -d "$dbname" -v "$output"
}
# generate new backup on heroku
heroku pg:backups:capture --app YOUR_HEROKU_APP_NAME_HERE
# download db locally
heroku pg:backups:download --app YOUR_HEROKU_APP_NAME_HERE --output=$output
# call dropDB function
dropDB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.