aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
diff options
context:
space:
mode:
authorGreg Navis <contact@gregnavis.com>2017-05-13 03:09:58 +0200
committerGreg Navis <contact@gregnavis.com>2017-11-30 10:46:38 +0100
commit1dca75c2c8f930b58d86cd2216af5e14307b3e53 (patch)
tree2c124dd35e87e3fc27448751e9d4001dd7e90fa5 /activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
parent1bee2fb600c07625b830afd33b43ead3364c9715 (diff)
downloadrails-1dca75c2c8f930b58d86cd2216af5e14307b3e53.tar.gz
rails-1dca75c2c8f930b58d86cd2216af5e14307b3e53.tar.bz2
rails-1dca75c2c8f930b58d86cd2216af5e14307b3e53.zip
Add support for PostgreSQL operator classes to add_index
Add support for specifying non-default operator classes in PostgreSQL indexes. An example CREATE INDEX query that becomes possible is: CREATE INDEX users_name ON users USING gist (name gist_trgm_ops); Previously it was possible to specify the `gist` index but not the custom operator class. The `add_index` call for the above query is: add_index :users, :name, using: :gist, opclasses: {name: :gist_trgm_ops}
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index be2f625d74..b66009bdc6 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -6,7 +6,7 @@ module ActiveRecord
# this type are typically created and returned by methods in database
# adapters. e.g. ActiveRecord::ConnectionAdapters::MySQL::SchemaStatements#indexes
class IndexDefinition # :nodoc:
- attr_reader :table, :name, :unique, :columns, :lengths, :orders, :where, :type, :using, :comment
+ attr_reader :table, :name, :unique, :columns, :lengths, :orders, :where, :type, :using, :opclass, :comment
def initialize(
table, name,
@@ -17,6 +17,7 @@ module ActiveRecord
where: nil,
type: nil,
using: nil,
+ opclass: {},
comment: nil
)
@table = table
@@ -28,6 +29,7 @@ module ActiveRecord
@where = where
@type = type
@using = using
+ @opclass = opclass
@comment = comment
end
end