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-2.5.2 lib/spree/migration_helpers.rb
solidus_core-2.5.1 lib/spree/migration_helpers.rb
solidus_core-2.5.0 lib/spree/migration_helpers.rb
solidus_core-2.5.0.rc1 lib/spree/migration_helpers.rb
solidus_core-2.5.0.beta2 lib/spree/migration_helpers.rb
solidus_core-2.5.0.beta1 lib/spree/migration_helpers.rb
solidus_core-2.4.2 lib/spree/migration_helpers.rb
solidus_core-2.3.1 lib/spree/migration_helpers.rb
solidus_core-2.4.1 lib/spree/migration_helpers.rb
solidus_core-2.2.2 lib/spree/migration_helpers.rb
solidus_core-2.1.1 lib/spree/migration_helpers.rb
solidus_core-2.0.3 lib/spree/migration_helpers.rb
solidus_core-1.4.2 lib/spree/migration_helpers.rb
solidus_core-1.3.2 lib/spree/migration_helpers.rb
solidus_core-1.2.3 lib/spree/migration_helpers.rb
solidus_core-2.4.0 lib/spree/migration_helpers.rb
solidus_core-2.4.0.rc1 lib/spree/migration_helpers.rb
solidus_core-2.4.0.beta1 lib/spree/migration_helpers.rb
solidus_core-2.3.0 lib/spree/migration_helpers.rb
solidus_core-2.3.0.rc3 lib/spree/migration_helpers.rb