参考:https://www.postgresql.org/docs/current/indexes-types.html

参考:https://apidock.com/rails/v5.2.3/ActiveRecord/ConnectionAdapters/SchemaStatements/add_index

使用migrate进行修改:

cat db/migrate/20221009081118_change_index_type_for_udts.rb
class ChangeIndexTypeForUdts < ActiveRecord::Migration[6.1]
  def self.up
    remove_index :udts, name: "index_udts_on_type_hash"
    add_index :udts, :type_hash, using: 'hash'
  end
  def self.down
    remove_index :udts, name: "index_udts_on_type_hash"
    add_index :udts, :type_hash
  end
end

运行bundle exec rake db:migrate

或者bundle exec rake db:rollback

可以进行创建,或者回退

只可以修改单个的index 为hash,混合列不可以

(access method "hash" does not support multicolumn indexes)