class ActiveSchema::Index

Public Class Methods

new(connection, table_name, columns, opts) click to toggle source
# File lib/active_schema/index.rb, line 4
def initialize connection, table_name, columns, opts
  @connection, @table_name, @columns, @opts = \
    connection, table_name, columns, opts

  # nothing to do if index of given columns with given opts already exists
  return if index_exists?(@opts)

  # if index of given columns exists and it has different options, remove it
  remove_index if index_exists?

  add_index
end

Private Instance Methods

add_index() click to toggle source
# File lib/active_schema/index.rb, line 23
def add_index
  @connection.add_index(@table_name, @columns, @opts)
end
index_exists?(opts = {}) click to toggle source
# File lib/active_schema/index.rb, line 19
def index_exists? opts = {}
  @connection.index_exists?(@table_name, @columns, opts)
end
remove_index() click to toggle source
# File lib/active_schema/index.rb, line 27
def remove_index
  # @connection.remove_index(@table_name, column: @columns)
end