Sha256: 886be24282d5ea92fc9e41d5fa531aca5dbe9bf51dd055298a1a83b8534da623

Contents?: true

Size: 778 Bytes

Versions: 47

Compression:

Stored size: 778 Bytes

Contents

# frozen_string_literal: true

require 'active_record/connection_adapters/abstract/schema_statements'

module Ridgepole
  module SchemaStatementsExt
    def index_name_exists?(*)
      if Ridgepole::ExecuteExpander.noop
        caller_methods = caller.map { |i| i =~ /:\d+:in `(.+)'/ ? Regexp.last_match(1) : '' }
        if caller_methods.any? { |i| i.start_with?('remove_index') }
          true
        elsif caller_methods.any? { |i| i.start_with?('add_index') }
          false
        else
          super
        end
      else
        super
      end
    end

    def rename_table_indexes(*)
      # Nothing to do
    end
  end
end

module ActiveRecord
  module ConnectionAdapters
    class AbstractAdapter
      prepend Ridgepole::SchemaStatementsExt
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
ridgepole-3.0.1 lib/ridgepole/schema_statements_ext.rb
ridgepole-3.0.0 lib/ridgepole/schema_statements_ext.rb
ridgepole-2.1.1 lib/ridgepole/schema_statements_ext.rb
ridgepole-2.1.0 lib/ridgepole/schema_statements_ext.rb
ridgepole-2.0.3 lib/ridgepole/schema_statements_ext.rb
ridgepole-2.0.2 lib/ridgepole/schema_statements_ext.rb
ridgepole-2.0.1 lib/ridgepole/schema_statements_ext.rb
ridgepole-2.0.0 lib/ridgepole/schema_statements_ext.rb
ridgepole-2.0.0.beta2 lib/ridgepole/schema_statements_ext.rb
ridgepole-2.0.0.beta lib/ridgepole/schema_statements_ext.rb
ridgepole-1.2.1 lib/ridgepole/schema_statements_ext.rb
ridgepole-1.2.0 lib/ridgepole/schema_statements_ext.rb
ridgepole-1.1.0 lib/ridgepole/schema_statements_ext.rb
ridgepole-1.0.7 lib/ridgepole/schema_statements_ext.rb
ridgepole-1.0.6 lib/ridgepole/schema_statements_ext.rb
ridgepole-1.0.5 lib/ridgepole/schema_statements_ext.rb
ridgepole-1.0.4 lib/ridgepole/schema_statements_ext.rb
ridgepole-1.0.3 lib/ridgepole/schema_statements_ext.rb
ridgepole-1.0.2 lib/ridgepole/schema_statements_ext.rb
ridgepole-1.0.2.beta lib/ridgepole/schema_statements_ext.rb