Skip to content

Instantly share code, notes, and snippets.

@graemeboyd
Created November 4, 2015 15:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graemeboyd/cc6f4a325283b8ef03d9 to your computer and use it in GitHub Desktop.
Save graemeboyd/cc6f4a325283b8ef03d9 to your computer and use it in GitHub Desktop.
Dump Heroku database structure and schema
# Sleep 5 tries to avoid Heroku truncating the output by terminating the connection before everything has transferred.
# Dump structure.sql as heroku_structure.sql
heroku run 'bundle exec rake db:structure:dump && cat db/structure.sql && sleep 5' --app app-name > db/heroku_structure.sql
# Dump schema.rb as heroku_schema.db
heroku run 'bundle exec rake db:schema:dump && cat db/schema.rb && sleep 5' --app app-name > db/heroku_schema.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment