【发布时间】:2018-10-18 17:11:00
【问题描述】:
更新我的 gem 后,我无法运行 rails db:schema:load。报错是:
ActiveRecord::MismatchedForeignKey: Column `user_id` on table
`user_applications` has a type of `int(11)`.
This does not match column `id` on `users`, which has type
`bigint(20)`.
这与从 rails 5.2(或 rails 5.1,我不知道)更改主键的一些默认 int 类型有关。我的问题是:我应该如何“迁移”数据库/模式?或者,我可以将主键设置为 32 位整数吗?因为我已经在application.rb试过了:
config.generators do |generator|
generator.orm :active_record, primary_key_type: :integer
end
但在运行上述任务时它没有做任何事情。
【问题讨论】:
标签: ruby-on-rails rails-migrations ruby-on-rails-5.1 ruby-on-rails-5.2