Reputation: 143
Heroku doesn't seem to update my database schema when I deploy. Here are the details:
Here is what is should look like for the User class:
create_table "users", :force => true do |t|
t.string "username"
t.datetime "created_at"
t.datetime "updated_at"
t.string "email"
t.string "encrypted_password"
t.string "salt"
t.string "remember_token"
t.boolean "admin", :default => false
end
Here is my deploy procedure:
git push heroku master
heroku rake db:migrate
heroku db:push
Everything seems to go smoothly... except that if I check the actually User table in db...
heroku console User
... I get an old version of User...
User(id: integer, username: string, created_at: datetime, updated_at: datetime)
Any idea what I am doing wrong? Thanks a lot for your help!
Simon
Upvotes: 12
Views: 7795
Reputation: 85
Run heroku rake run db:migrate
Then heroku restart
Refresh your web page and it should all work.
Upvotes: -1
Reputation: 126
You might want to try
heroku run rake db:migrate
heroku restart
Hope this helps.
Upvotes: 1
Reputation: 3938
The accepted answer is right. FYI though, you now use heroku run rake db:migrate
because heroku rake db:migrate
is deprecated
Upvotes: 0
Reputation: 34942
Do you see any output when you heroku rake db:migrate
?
Try running heroku restart
after you migrate to restart the web servers and DJ workers. That shouldn't influence your console, but I have seen web servers serving old versions of the code immediately after a deploy, which normally isn't a problem but with pending migrations can be.
Upvotes: 24