开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜