0
Rails 5允許使用UUID作爲主鍵。我最近從Rails 4遷移到了5,並希望利用此功能。我現在的表有兩個UUID和序列ID:Rails 5 - 遷移到使用UUID作爲主鍵
schema.rb:
create_table "customers", id: :serial, force: :cascade do |t|
t.uuid "uuid", default: -> { "gen_random_uuid()" }, null: false
# other stuff...
end
什麼會遷移樣子擺脫的id和UUID設置主鍵?
你有其他表指向'users.id'(又名:'belongs_to:user')的外鍵嗎? – spickermann