instance method
index
Ruby on Rails 8.0.4
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 -
optionskeyrest
Source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb, line 756
def index(column_name, **options)
raise_on_if_exist_options(options)
@base.add_index(name, column_name, **options)
end
Defined in activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb line 756
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::ConnectionAdapters::Table