Sha256: e53604f3fce3866e66af24e8f6ca46aa879de4b4a1908218056a934e92c1208d

Contents?: true

Size: 493 Bytes

Versions: 43

Compression:

Stored size: 493 Bytes

Contents

module Spree
  module MigrationHelpers
    def safe_remove_index(table, column)
      remove_index(table, column) if index_exists?(table, column)
    end

    def safe_add_index(table, column, options = {})
      if columns_exist?(table, column) && !index_exists?(table, column, options)
        add_index(table, column, options)
      end
    end

    private

    def columns_exist?(table, columns)
      Array.wrap(columns).all? { |column| column_exists?(table, column) }
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
solidus_core-1.3.0 lib/spree/migration_helpers.rb
solidus_core-1.3.0.rc2 lib/spree/migration_helpers.rb
solidus_core-1.3.0.rc1 lib/spree/migration_helpers.rb