【发布时间】:2018-03-23 15:39:47
【问题描述】:
在我的 Rails 应用的 schema.rb 中,我有:
create_table "reviews", force: :cascade do |t|
t.integer "user_id"
t.integer "venue_id"
t.integer "rating", limit: 2
t.text "body"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "treatments"
end
“治疗”是一个序列化的字段:
class Review < ActiveRecord::Base
serialize :treatments
...
end
我需要将“治疗”字段迁移到:
t.string "treatments", default: [], null: false, array: true
适当的迁移应该是什么样的?
【问题讨论】:
标签: ruby-on-rails serialization migration