diff options
author | Grey Baker <greysteil@gmail.com> | 2015-08-21 12:44:59 +0100 |
---|---|---|
committer | Grey Baker <greysteil@gmail.com> | 2015-09-05 17:04:03 +0100 |
commit | ce17e232a12861bce4bd950d7143df3fe0cd1991 (patch) | |
tree | f907768be0c7fafc367a228637815213dfee7969 /activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | |
parent | a8f4568f5396b68ae81eddc636604bb78bb6632a (diff) | |
download | rails-ce17e232a12861bce4bd950d7143df3fe0cd1991.tar.gz rails-ce17e232a12861bce4bd950d7143df3fe0cd1991.tar.bz2 rails-ce17e232a12861bce4bd950d7143df3fe0cd1991.zip |
Support dropping indexes concurrently in Postgres
See http://www.postgresql.org/docs/9.4/static/sql-dropindex.html
for more details.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb index a3fc8fbc51..26ef23a0d9 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb @@ -447,8 +447,15 @@ module ActiveRecord execute "CREATE #{index_type} INDEX #{index_algorithm} #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} #{index_using} (#{index_columns})#{index_options}" end - def remove_index!(table_name, index_name) #:nodoc: - execute "DROP INDEX #{quote_table_name(index_name)}" + def remove_index(table_name, options = {}) #:nodoc: + index_name = index_name_for_remove(table_name, options) + algorithm = + if options.key?(:algorithm) + index_algorithms.fetch(options[:algorithm]) do + raise ArgumentError.new("Algorithm must be one of the following: #{index_algorithms.keys.map(&:inspect).join(', ')}") + end + end + execute "DROP INDEX #{algorithm} #{quote_table_name(index_name)}" end # Renames an index of a table. Raises error if length of new |