Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Joe Dayvie
Joe Dayvie
11,956 Points

Heroku: Pulling/Restore Database

Hello,

I have been asking this question elsewhere and have been unable to retrieve any answers so I thought it would be worth asking here.

Long story short, I have a Rails App that has one database (with various tables). While trying to achieve friendly_ids, I ran into problems and ultimately rolled back the database too far. I ended up deleting all databases but with db:migrate, they all returned. Problem is all the data was erased on my localhost.

This is okay because my launched website (http://www.joedayvie.com) still has the all the data (via Heroku). My fear is when I push content or db:migrate to Heroku, my website data will be wiped. To resolve this, I have been researching heroku pg:pull and heroku pg_restore. I successfully just completed a pg:pull but I do not see any changes in my localhost data. Pg_restore does not successfully work so I am at a standstill.

I never had my localhost and website match with data (which I have now been told they always should), so hopefully there is some way for me to complete this and grab the data from my website and place it onto my localhost. That way everything can go back to normal.

If you have any advice please let me know. I am desperate and have read many Heroku Tutorials, Stackoverflow, etc. but haven't been able to find a resolution and I am afraid to continue and ultimately lose everything.

Thank you!

  • Joe
Joe Dayvie
Joe Dayvie
11,956 Points

Update: I have since used pg_restore successfully; however, there are still no changes to my localhost. Even after restarting the Rails Server...

2 Answers

Seth Kroger
Seth Kroger
56,413 Points

Isn't your localhost running under the development environment while Heroku is running under production? Because there are two separate databases for each environment.

Joe Dayvie
Joe Dayvie
11,956 Points

Seth,

Yeah, after speaking with another individual and helping me, it was because Heroku uses Postgres and I had Sqlite3 (because that is what I first saw via Treehouse). It was best to simply remove Sqlite3 completely and now I strictly use PG for my Rails Blog =) I actually wrote a blog post about the matter and how I resolved it (http://www.joedayvie.com/articles/11).

Thank you!

Joe