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

前端 未结 4 652
不思量自难忘°
不思量自难忘° 2020-12-14 09:37

I have a problem with pushing my migrations to the production database.

The issue:

  1. I\'ve altered database schema by adding 1 column.
  2. I\'ve

相关标签:
4条回答
  • 2020-12-14 10:02

    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.

    0 讨论(0)
  • 2020-12-14 10:07

    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.

    0 讨论(0)
  • 2020-12-14 10:07

    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]

    0 讨论(0)
  • 2020-12-14 10:23

    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

    0 讨论(0)
提交回复
热议问题