instance method
index
Ruby on Rails 5.2.8.1
Since v2.2.3Signature
index(column_name, options = {})
Adds a new index to the table. column_name can be a single Symbol, or an Array of Symbols.
t.index(:name) t.index([:branch_id, :party_id], unique: true) t.index([:branch_id, :party_id], unique: true, name: 'by_branch_party')
See connection.add_index for details of the options you can use.
Parameters
-
column_namereq -
optionsopt = {}
Source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb, line 547
def index(column_name, options = {})
@base.add_index(name, column_name, options)
end
Defined in activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb line 547
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::Table