开发者

Rails 3 Migration not working on Heroku

I have a very simple migration which was created using the generator

class AddEmailToUsers < ActiveRecord::Migration
  def self.up
    add_column :users, :email, :string
  end

  def self.down
    remove_column :users, :email
  end
end

It works great locally

rake db:migrate
rails console
>> User.column_names
=> ["id", "created_at", "updated_at", "uid", "provider", "name", "role", "email"]

I have two versions of the app on Heroku. In one, it works fine. In the other, the column simply doesn't show up.

The output from heroku rake db:migrate looks right:

==  AddEmailToUsers: migrating ================================================
-- add_column(:users, :email, :string)
   -> 0.0031s
==  AddEmailToUsers: migrated (0.0032s) =======================================

But the column isn't there:

>> User.column_names
=> 开发者_Go百科["id", "created_at", "updated_at", "uid", "provider", "name", "role"]

(By the way, all my database changes have been via generator-created migrations; I haven't touched SQL myself nor edited any migration files.)

This is a production environment so dropping the table is not an option.

Any suggestions for things I can try?


heroku restart

fixes the issue for me.

I think this is a bug in the heroku system. I've just emailed them asking for a fix.


Did you run "heroku rake db:migrate" ? This runs migrations not locally, but on Heroku.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜