change_column_default
change_column_default(table_name, column_name, default_or_changes)
public
Sets a new default value for a column:
change_column_default(:suppliers, :qualification, 'new') change_column_default(:accounts, :authorized, 1)
Setting the default to nil effectively drops the default:
change_column_default(:users, :email, nil)
Passing a hash containing :from and :to will make this change reversible in migration:
change_column_default(:posts, :state, from: nil, to: "draft")
Implemented in database adapters
These methods are not implemented in the abstract classes. Instead, all database adapters implement these separately, if the feature is supported.
How to set default value to NULL
To set default value to NULL you can use change_column method instead, for example:
change_column :suppliers, :qualification, :string, :default => nil
Just make sure you don’t change data type accidentally ;-)
Not implented yet
According to this method’s source, change_column_default is not implemented as well as change_column
change_column did the trick for me
Use change_column, and make sure to specify the datatype:
class ChangeUsers < ActiveRecord::Migration def up change_column :users, :is_vote_reminder, :boolean, :default => true end end