module Spree::MigrationHelpers

Public Instance Methods

safe_add_index(table, column, options = {}) click to toggle source
# File lib/spree/migration_helpers.rb, line 9
def safe_add_index(table, column, options = {})
  if columns_exist?(table, column) && !index_exists?(table, column, options)
    add_index(table, column, options)
  end
end
safe_remove_index(table, column) click to toggle source
# File lib/spree/migration_helpers.rb, line 5
def safe_remove_index(table, column)
  remove_index(table, column) if index_exists?(table, column)
end

Private Instance Methods

columns_exist?(table, columns) click to toggle source
# File lib/spree/migration_helpers.rb, line 17
def columns_exist?(table, columns)
  Array.wrap(columns).all? { |column| column_exists?(table, column) }
end