Sha256: e92ec4810af73f3945377cf812d367369b3152d2252b7777504990bcf869c3d6

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'active_record/connection_adapters/abstract_mysql_adapter'

module Ridgepole
  module Ext
    module AbstractMysqlAdapter
      module UseAlterIndex
        def add_index(table_name, column_name, options = {})
          index_name, index_type, index_columns, index_options, _index_algorithm, index_using = add_index_options(table_name, column_name, options)

          # cannot specify index_algorithm
          execute "ALTER TABLE #{quote_table_name(table_name)} ADD #{index_type} INDEX #{quote_column_name(index_name)} #{index_using} (#{index_columns})#{index_options}"
        end

        def remove_index(table_name, options)
          index_name = index_name_for_remove(table_name, options)
          execute "ALTER TABLE #{quote_table_name(table_name)} DROP INDEX #{quote_column_name(index_name)}"
        end
      end
    end
  end
end

module ActiveRecord
  module ConnectionAdapters
    class AbstractMysqlAdapter
      prepend Ridgepole::Ext::AbstractMysqlAdapter::UseAlterIndex
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ridgepole-0.8.10 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.8.9 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.8.8 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.8.7 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.8.6 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.8.5 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.8.4 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.8.3 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.8.2 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.8.1 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.8.0 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.8.0.rc2 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb
ridgepole-0.7.8 lib/ridgepole/ext/abstract_mysql_adapter/use_alter_index.rb