rails/rails — Issue #3495: change_column ignores new :default option
Author: intechltd
Created: 2011-11-02 16:33:42+00:00
State: open

Initial DB struct:

class CreateClients < ActiveRecord::Migration
def change
create_table :clients do |t|
t.string :name, :null => false
t.string :address, :null => false
t.string :currency, :limit => 3, :default => Money.default_currency.to_s, :null => false
end
add_index :clients, :name
end
end

After applying the following migration the default value should be NONE, but it remains the same as it was in initial migration. In my opinion if :default is set to nil it should be defined as NONE (not just NULL) in the database.

class RemoveClientDefaultCurrency < ActiveRecord::Migration
def up
change_column :clients, :currency, :string, :default => nil, :limit => 3, :null => false
end

def down
change_column :clients, :currency, :string, :limit => 3, :null => false, :default => Money.default_currency.to_s
end
end