I followed this tutorial to make a simple website where you can enter blog entries. I was able to get it working with a postgresql database on my computer.
Then I pushed it to heroku. It was accepted and everything seemed fine.
When I tried to go to the page in my browser though, it didn't work right. You can see it here.
I even tried setting up a shared postgresql database on Heroku. Am I supposed to make some changes to database.yml to get it to work?
One thing I noticed though is that what I added in the shared postgresql database, the error messages seem to indicate that it does find a database, but doesn't find the table. Am I right? I tried to manually recreate the table using the heroku console, but wasn't able to.
What's going on here? How can I get this to work?
Have you tried heroku run rake db:migrate yet?
If that doesn't fix it what does heroku logs --tail tell you?
Related
So I believe that I have searched on here and not found any question that pertains to my issue so hopefully someone can guide me. I was required (for a course) to create a Ruby scaffolding "products" page. My page links all worked on the local host rails server but when I tried it on Heroku (also required) all the links work EXCEPT the new product page.
I have exhaustively googled but I must admit that all the computer lingo is new to me so I am unsure what any of it means and of what steps are safe. For the reason that if I make things worse, I will never know what to look for to reverse anything. I have included the error that shows up in Heroku. When I searched that I found many different answers causing me to be unsure which is correct.
If anything else is needed just let me know. Many thanks to any and all that reply!
Error on Heroku
The error says, "relation products" does not exist.
Did you make sure to run heroku run rake db:migrate ? After you migrate you'll need to heroku restart
This gets me a lot as part of my Heroku deployments, so I make sure to write a script or rake task which does the git push to deploy to Heroku, then runs these two commands. Then I always use that script to deploy, instead of manually doing a push.
i'm working on a Ruby on rails project adopted by another developer. It's deployed on heroku, uses heroku postgreSQL.
When i run the project on my local rails server with the remote database, it works fine. But there is one problem: I would like to delete some entries. So I tried to connect via PostgreSQL-Console. But it seems like the PostgrqSQL-Console gives me another version of the database than the one who is used by the app.
For example, the latest user ID in the app is 540 and in the database displayed by the console only 500.
Any idea? Thank you in advance.
Problem is solved. The elastic search index wasn't synchronized. Thank you for your help anyway.
I've completed the Rails Tutorial. I kept up with every detail until the end of chapter 8. The last four chapters I just copied and pasted without trying to understand much.
The Sample App works perfectly on a Cloud9 local web server, but not on Heroku. Specifically, When I want to sign up a new user, I get the message "We're sorry, but something went wrong."
Why can I sign up a new user without problems on the local server but not on Heroku? Is the functionality of the final sample app supposed to be exactly the same on both local and heroku?
You are getting a 500, look at the server logs for a clue. Probably need to run migrations.
Run your migrations:
heroku run rake:db migrate
You may need to restart heroku:
heroku restart
If it still doesn't work, try resetting your database. If you're using postgres, try:
heroku pg:reset DATABASE
I completed every step in the entire Rails Tutorial book, except one, which I thought was optional and wouldn't affect the result in production.
10.3 Email in Production shows you how to configure your application to send emails in production (for account activation in the book's sample application) using a Heroku add-on called Sendgrid.
You do have to give Heroku credit card information (though for the purposes of the book you don't have to actually make any purchase or subscription), and this is why I initially didn't implement this section of the book.
After following along and implementing section 10.3 my final application is fully functional in production.
I have screwed up my migrations/schema/db to the point that I can't seem to figure this out.
Locally, I had a comments table. I needed to restructure this table completely, so I opened up my initial "create comments table" migration and altered it manually. I then altered my schema.rb file to match the migration. I then ran rake db:reset and rebuilt my database, and rake db:migrate to finish it off.
This worked seemingly well on my local dev environment. When I pushed to heroku, however, I ran heroku pg:psql and dropped my comments table. I then ran heroku run rake db:migrate thinking it would rebuild the comments table - It did not. The comments table no longer exists, and I can't figure out how to recreate it. I don't have anything important in my heroku database EXCEPT for the users table, so I can't reset the entire thing.
How can I recreate that table, and make sure it matches the migration file I pushed to heroku?
First off, you shouldn't go back into old migrations and manually change them. Just do a new migration with the changes defined there. Read up on migrations here: http://guides.rubyonrails.org/migrations.html
This is done so you don't run into the problem you are currently having. It's also bad practice and if you were working in a group there would be complete mayhem. It's hard to tell exactly what the differences are between your local machine and heroku and what you've changed. My suggestion would be to roll back both your local machine and heroku and do a new migration with your changes.
I'm assuming you are using git so you can go back to a previous version before the change to the create_comments_table on your local machine. You can do the same in Heroku at
https://dashboard.heroku.com/apps/nameofyourapp/activity
In your dashboard you can click on your app and go to the activity tab. There heroku maintains a record of the changes you've pushed. You can rollback to another previous change by hovering over the version.
Now that you have basically restart your app locally and on heroku, you can define a migration with what you want to change in the comments table.
You also might be interested in the PG Backup add-on. Then you won't be as worried about losing data. https://devcenter.heroku.com/articles/pgbackups
I recently did Heroku's requested database migration from a "shared database" to Postgres. I followed Heroku's directions carefully, and it all went fine until the last step: removing the old shared database. At that point, my app went down with the "something went wrong" message, and it's been down ever since (going on two weeks now).
Note that the app was still working after the step in which I switched to the new database, and according to "heroku config", it is using the new database. It shouldn't care about the old one disappearing. The logs say nothing other than 500 errors.
I submitted an urgent support request to Heroku, but they were not helpful. They just said that my data is still there but, "Your application isn't logging so it's not clear why this is happening but it doesn't appear to be due to the migration." That was a week ago, so it's not looking like they're going to do anything more.
I agree that the problem shouldn't be due to the migration, but given that I've made no changes to the app except the migration, and that it died exactly when I removed the old database, I don't see what else it could be.
My app is probably pretty old at this point (Rails 3.0.3), so my only thought now is to update everything to the latest versions and redeploy. The app is used to record merit badges and rank advancements for our local Boy Scout troop, so I really need to get it running again. Any advice would be greatly appreciated.
My first instinct would to db:pull the heroku hosted database. (make a copy).
Then try to start your app locally.
Heroku has fixed the problem. My hypothesis was correct: my app was so old that the migration procedure did not actually update it to use the new database. They say that they'll be applying the fix to their other old apps now.
If the app started failing the moment you removed the shared database, it means that your app was still connected to this database and was never connecting to the new one. It sounds to me like you did not run heroku pg:promote HEROKU_POSTGRESQL_<color of new database> --app <your-app>. Can you try that?
Edit:
Based on the further info provided in your comments, it's possible that this is a potential issue in the aspen and bamboo stacks (that only affect a few customers). The thing to try now is a new deploy. Try making a trivial change - maybe a newline in your project README - and deploy the app again. This will force a slug recompile that will write out a new database.yml using the correct DB.
Even better would be to migrate to the cedar stack though