首页 > 解决方案 > 在使用 Postgres 的 Rails 中,如何在 UUID 数组上添加索引?

问题描述

我正在尝试使用 Postgres 9.6 在 Rails 中的 UUID 数组上添加索引。这是我的迁移...

class AddProductIdsToApplications < ActiveRecord::Migration[5.2]
  def change
    add_column :applications, :product_ids, :uuid, array: true, default: [] 
    add_index :applications, :product_ids, using: 'gin'
  end
end

我收到这个错误...

>     PG::UndefinedObject: ERROR:  data type uuid[] has no default operator class for access method "gin"
>     HINT:  You must specify an operator class for the index or define a default operator class for the data type.

是否有针对此的迁移修复?

标签: postgresqlruby-on-rails-5uuid

解决方案


推荐阅读