如何将默认值添加到RoR迁移中的字段?(How do I add a default value to a field in a RoR migration?)
如何将默认值添加到RoR迁移中的现有字段?
How do I add a default value to an existing field in a RoR migration?
最满意答案
我认为这会做到这一点
change_column :users, :active, :boolean, :default => 1使用与创建列时相同的数据类型,但添加默认参数。
I think this would do the trick
change_column :users, :active, :boolean, :default => 1Use the same data type as when you created the column but add the default parameter.
如何将默认值添加到RoR迁移中的字段?(How do I add a default value to a field in a RoR migration?)如何将默认值添加到RoR迁移中的现有字段?
How do I add a default value to an existing field in a RoR migration?
最满意答案
我认为这会做到这一点
change_column :users, :active, :boolean, :default => 1使用与创建列时相同的数据类型,但添加默认参数。
I think this would do the trick
change_column :users, :active, :boolean, :default => 1Use the same data type as when you created the column but add the default parameter.
发布评论