我正在尝试使用 ActiveImport 进行更新。运行导入时,我试图向它传递一个命名约束,以便告诉它何时更新某些列。
User.import(
@import_values,
on_duplicate_key_update: {
constraint_name: :index_users_on_uid_and_tenant_id,
columns: %i[title location_id email active]
}
)
上面的代码是我的导入语句,根据 activeimport 文档是正确的。但是,当我运行它时,我得到 PG:UndefinedObject 错误,它显示以下内容:
Caused by PG::UndefinedObject: ERROR: constraint "index_users_on_uid_and_tenant_id" for table "users" does not exist
但是,在我的 schema.rb 中,在我的 users 表模式中,约束显然存在:
t.index ["uid", "tenant_id"], name: "index_users_on_uid_and_tenant_id", unique: true
而且,这将返回 true:
ActiveRecord::Base.connection.index_exists?(:users, [:uid, :tenant_id]) => true
关于为什么会发生这种情况的任何帮助都会非常有帮助!