How to set default value for new objects only, in Rails Migration? -
i know how set default value column in rails, find myself in situation this, example :
boolean field named 'settled', default value false
new objects not settled until so, need old objects settled
what making rake task toggle old objects, there way in migration not script, set value default old objects not future schema
you can in migration:
add_column :users, :is_banned, :bool user.update_all(is_banned: false)
Comments
Post a Comment