Module: ActiveRecord::ConnectionAdapters::SchemaStatements

Defined in:
lib/pg_index_where/schema_statements.rb

Instance Method Summary collapse

Instance Method Details

#add_index(table_name, column_name, options = {}) ⇒ Object



4
5
6
7
8
# File 'lib/pg_index_where/schema_statements.rb', line 4

def add_index(table_name, column_name, options = {})
  where = options[:where] ? "where #{options[:where]}" : ''
  index_name, index_type, index_columns = add_index_options(table_name, column_name, options)
  execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{index_columns}) #{where}"
end