Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
=> ["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?

like image 796
Francis Potter Avatar asked Dec 17 '22 16:12

Francis Potter


1 Answers

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.

like image 118
Jack Kinsella Avatar answered Jan 01 '23 07:01

Jack Kinsella