开发者

Is it possible to retroactively add properties to DB-columns using Rails?

开发者 https://www.devze.com 2023-03-03 04:10 出处:网络
When you have a database populated with data, is it possible to add for instance :default =开发者_StackOverflow> 0

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

精彩评论

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