Heroku run rake db:migrate results in no change in the database, app restarted several times

会有一股神秘感。 提交于 2019-11-28 20:39:29

It doesn't look like you are pushing changes to Heroku. Steps should be as follows;

  1. Make changes to local code
  2. Run any migrations LOCALLY
  3. Add all changed files to Git git add .
  4. Commit all added files to git git commit -m "Adding features"
  5. Push the changes to Heroku git push heroku master - assuming you are using heroku as your remote name and you are working in the master branch
  6. If you have migrations run heroku run rake db:migrate to run the migrations ON HEROKU
  7. Following migrations do heroku restart

That should be all you need to get you working.

I had the same problem; I git added the migrations, git pushed them to the server, cap deployed them, and the database didn't change. Logged in to the server directly, ran rake db:migrate, and the command line seemed to run the migration, but nothing changed.

In my case, somehow rake db:migrate was using the wrong RAILS_ENV. I logged in to the server, and ran

rake db:migrate RAILS_ENV=production

This caused the database to create the new columns, and then all of the code that I had debugged in the test database started working on the server.

I just had same problem. After adding a column to my DB locally, I did heroku run rake db:migrate -app [my app name]. Running my code on production, I got ActiveRecord::UnknownAttributeError (unknown attribute '_____' for [table name].)

This solved my problem:

heroku restart --app [my app name]

My two cents based on my experience: I thought that heroku run db:migrate also migrated db content into production. No! Only structure. So in my case, log in was not working in production because there were no users in it. I had to sign test user up again and then it worked. Hope it helps rookies like me out there

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!