diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-03-26 07:18:21 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-03-26 07:18:21 -0700 |
commit | 2d33796457b139a58539c890624591c97354d334 (patch) | |
tree | dd43c9a7a61bc3bb6f90f0414ebf3d9860931949 /activerecord/lib/active_record/connection_adapters/abstract | |
parent | 078bfbffa41e29a9d8ff2cf56e4c9254e7260f24 (diff) | |
parent | 203e0e0e4a863a25fedfe6985b371c3f4cfc6839 (diff) | |
download | rails-2d33796457b139a58539c890624591c97354d334.tar.gz rails-2d33796457b139a58539c890624591c97354d334.tar.bz2 rails-2d33796457b139a58539c890624591c97354d334.zip |
Merge pull request #9923 from danmcclain/psql-concurrent-indexes
Adds support for concurrent indexing in PostgreSQL adapter
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 26cacbde37..d5ae4058ed 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -752,12 +752,20 @@ module ActiveRecord index_name = index_name(table_name, column: column_names) if Hash === options # legacy support, since this param was a string - options.assert_valid_keys(:unique, :order, :name, :where, :length, :internal, :using) + options.assert_valid_keys(:unique, :order, :name, :where, :length, :internal, :using, :algorithm) index_type = options[:unique] ? "UNIQUE" : "" index_name = options[:name].to_s if options.key?(:name) max_index_length = options.fetch(:internal, false) ? index_name_length : allowed_index_name_length + if index_algorithms.key?(options[:algorithm]) + algorithm = index_algorithms[options[:algorithm]] + elsif options[:algorithm].present? + raise ArgumentError.new("Algorithm must be one of the following: #{index_algorithms.keys.map(&:inspect).join(', ')}") + end + + using = "USING #{options[:using]}" if options[:using].present? + if supports_partial_index? index_options = options[:where] ? " WHERE #{options[:where]}" : "" end @@ -772,6 +780,7 @@ module ActiveRecord index_type = options max_index_length = allowed_index_name_length + algorithm = using = nil end if index_name.length > max_index_length @@ -782,7 +791,7 @@ module ActiveRecord end index_columns = quoted_columns_for_index(column_names, options).join(", ") - [index_name, index_type, index_columns, index_options] + [index_name, index_type, index_columns, index_options, algorithm, using] end def index_name_for_remove(table_name, options = {}) |