views:

84

answers:

1

I've got a very simple migration that adds a single boolean column:

class AddMuteToPreferences < ActiveRecord::Migration
  def self.up
    add_column :preferences, :mute_audio, :boolean, :default => false
  end

  def self.down
    remove_column :preferences, :mute_audio
  end
end

I run the migration:

== 81 AddMuteToPreferences: migrating =========================================
-- add_column(:preferences, :mute_audio, :boolean, {:default=>false})
   -> 1.9043s
== 81 AddMuteToPreferences: migrated (1.9047s) ================================

Looks peachy, right? But, for some reason, there's still no mute_audio column in my preferences table.

I can't figure it out. I've executed add_column before with no problems.

Has anyone ever seen this behavior before?

+3  A: 

I see no reason for rails to fail the add of the column. You are probably looking in the wrong database.

The best way to debug this is to enter rails console mode:

script/console development

And create a new preference object and give mute_audio a value:

>> p = Preference.new
(...)
>> p.mute_audio = true

After the first command, you should see some output containing info about the newly created object. You should see that it has mute_autio: false. If setting the attribute mute_audio does not output an error, there's no problem and the new added column is there.

rogeriopvl