Add a default value to a column through a migration

Solution 1:

Here's how you should do it:

change_column :users, :admin, :boolean, :default => false

But some databases, like PostgreSQL, will not update the field for rows previously created, so make sure you update the field manaully on the migration too.

Solution 2:

change_column_default :employees, :foreign, false

Solution 3:

For Rails 4+, use change_column_default

def change
  change_column_default :table, :column, value
end