Is it possible to retroactively add properties to DB-columns using Rails?
When you have a database populated with data, is it possible to add for instance
:default =开发者_StackOverflow> 0
to one of the columns, by using for instance a migration in Rails?
Create a new migration
# Rails 3:
rails g migration change_default_on_column_in_table
# or older Rails:
script/generate migration change_default_on_column_in_table
and use :
change_column_default(:table, :column, 0)
See the Rails documentation for more information.
精彩评论