lib/active_record/connection_adapters/percona_adapter.rb
# Adds a new index to the table
#
# @param table_name [String, Symbol]
# @param column_name [String, Symbol]
# @param options [Hash] optional
Adds a new index to the table
Adds a new index to the table
def add_index(table_name, column_name, options = {})
        if ActiveRecord::VERSION::STRING >= '6.1'
          index_definition, = add_index_options(table_name, column_name, **options)
          execute <<-SQL.squish
            ALTER TABLE #{quote_table_name(index_definition.table)}
              ADD #{schema_creation.accept(index_definition)}
          SQL
        else
          index_name, index_type, index_columns, index_options = add_index_options(table_name, column_name, **options)
          execute <<-SQL.squish
            ALTER TABLE #{quote_table_name(table_name)}
              ADD #{index_type} INDEX
              #{quote_column_name(index_name)} (#{index_columns})#{index_options}
          SQL
        end
      end
def add_index ( table_name , column_name , options = { } ) if ActiveRecord :: VERSION :: STRING >= '6.1' index_definition , = add_index_options ( table_name , column_name , ** options ) execute <<-SQL . squish 
            ALTER TABLE  #{ quote_table_name ( index_definition . table ) } 
              ADD  #{ schema_creation . accept ( index_definition ) } SQL else index_name , index_type , index_columns , index_options = add_index_options ( table_name , column_name , ** options ) execute <<-SQL . squish 
            ALTER TABLE  #{ quote_table_name ( table_name ) } 
              ADD  #{ index_type }  INDEX
               #{ quote_column_name ( index_name ) }  ( #{ index_columns } ) #{ index_options } SQL end end
Adds a new index to the table
Adds a new index to the table
table_name
column_name
options
None
None