Reputation: 1025
I have some data in my postgresql database that I entered using a very simple rails app. I deployed it to heroku and now am trying to send my local database to heroku because its very empty right now.
At first I thought doing heroku run rake db:migrate
would actually do this but turns out it only creates tables in heroku?
These are the steps I took to transfer my local database to heroku.
1: heroku run rake db:migrate
( I did this to create tables which should be empty right?)
2: heroku pg:push my_db DATABASE_URL --app my-herokuapp-98989
(the actual syntax to transfer database)
Here, it said
"Remote database is not empty. Please create a new database or use heroku pg:reset
"
4: heroku pg:reset DATABASE
"WARNING: Destructive action"
"postgresql-amorphous-59192 will lose all of its data"
"To proceed, type my-herokuapp-98989 or re-run this command with --confirm my-herokuapp-98989
5: my-herokuapp-98989
"Resetting postgresql-amorphous-59192... done
"
After this I try to open my app but it gives off an error saying
"ActionView::Template::Error (PG::UndefinedTable: ERROR: relation "drinks" does not exist"
"2017-07-29T04:50:20.697828+00:00 app[web.1]: LINE 1: SELECT "drinks".* FROM "drinks""
"drinks" is the name of my table and I think it is giving this error because I just reset my database so there is no table or columns and rows?
So again I try pushing my database to heroku and it just freezes at this point
6: heroku pg:push my_db DATABASE_URL --app my-herokuapp-98989
"heroku-cli: Pushing my_db ---> postgresql-amorphous-59192
"
...and it freezes here
What am I doing wrong? Please help.
Upvotes: 1
Views: 535
Reputation: 2502
are you sure it's freezing? or its just loading, because you need to upload the dumpfile to heroku.
you also can try this command
heroku pg:backups:restore 'https://url/where/heroku/can/download/yourdbdump.dump' DATABASE_URL
more about import export you can read here. https://devcenter.heroku.com/articles/heroku-postgres-import-export#import
Upvotes: 1