How do I add a default value to a column that already exists through a migration?
All the documentation I can find shows you how to do it if the column doesn\'t alr
Execute:
rails generate migration add_column_to_table column:boolean
It will generate this migration:
class AddColumnToTable < ActiveRecord::Migration
def change
add_column :table, :column, :boolean
end
end
Set the default value adding :default => 1
add_column :table, :column, :boolean, :default => 1
Run:
rake db:migrate