method
index_exists?
v3.0.0 -
Show latest stable
- Class:
ActiveRecord::ConnectionAdapters::SchemaStatements
index_exists?(table_name, column_name, options = {})public
Checks to see if an index exists on a table for a given index definition
Examples
# Check an index exists index_exists?(:suppliers, :company_id) # Check an index on multiple columns exists index_exists?(:suppliers, [:company_id, :company_type]) # Check a unique index exists index_exists?(:suppliers, :company_id, :unique => true) # Check an index with a custom name exists index_exists?(:suppliers, :company_id, :name => "idx_company_id"