To delete it beforehand, you can run: $ dropdb mylocaldbįor my own workflow combine them and use a Bash alias to make it easier to run: alias prdb="dropdb preceden_production_copy PGUSER=postgres PGPASSWORD=password heroku pg:pull HEROKU_POSTGRESQL_MAGENTA preceden_production_copy -app sushi" In order for this command to work, mylocaldb can’t exist when you run this command. If your local Postgres instance requires a user name and password, you can provide them via the command line as well: $ PGUSER=postgres PGPASSWORD=password heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb -app sushi Where mylocaldb is the name of a local Postgres database, sushi is the name of your Heroku app, and HEROKU_POSTGRESQL_MAGENT is the name of your database which you can obtain by running: $ heroku pg:info -a sushi Heroku makes this fairly easy using the pg:pull command: $ heroku pg:pull HEROKU_POSTGRESQL_MAGENTA mylocaldb -app sushi Step 1: Pull your production data into a local Postgres database Wouldn’t it be nice if you could quickly query your database and explore the results?įortunately there is a way using a combination of Heroku’s pg:pull feature and a Mac app called SQLPro for Postgres. Neither option makes it easy to quickly explore the data. Rake tasks let you perform complex analyses, but make it difficult to explore data because each time you tweak your task to do something new, you need to commit, push to production, run the task, and wait for it to execute. Each method has limitations though: heroku console makes easy to answer simple questions about your data, but makes it difficult to perform complicated analyses that take more than a few lines of code. In the past when I’ve wanted to explore production data for a Heroku-hosted Ruby on Rails app, I’ve primarily used heroku console and rake tasks.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |