diff options
author | doabit <doinsist@gmail.com> | 2013-03-24 05:09:54 +0800 |
---|---|---|
committer | doabit <doinsist@gmail.com> | 2013-03-24 05:09:54 +0800 |
commit | 8094156728f72d493916e3d3a8c8d90c5f2d79c0 (patch) | |
tree | 4772eec9db0ed9316941aee23fa5dd038587b3f9 /activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | |
parent | 9e8b7d9d5bb3537f113fbda2a1720c5f412fbe62 (diff) | |
download | rails-8094156728f72d493916e3d3a8c8d90c5f2d79c0.tar.gz rails-8094156728f72d493916e3d3a8c8d90c5f2d79c0.tar.bz2 rails-8094156728f72d493916e3d3a8c8d90c5f2d79c0.zip |
Custom index type support with :using.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 11 |
1 files changed, 9 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 a26a0b54ea..26cacbde37 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -497,7 +497,14 @@ module ActiveRecord # # CREATE UNIQUE INDEX index_accounts_on_branch_id_and_party_id ON accounts(branch_id, party_id) WHERE active # - # Note: only supported by PostgreSQL. + # ====== Creating an index with a specific method + # add_index(:developers, :name, :using => 'btree') + # generates + # CREATE INDEX index_developers_on_name ON developers USING btree (name) -- PostgreSQL + # CREATE INDEX index_developers_on_name USING btree ON developers (name) -- MySQL + # + # Note: only supported by PostgreSQL and MySQL + # def add_index(table_name, column_name, options = {}) index_name, index_type, index_columns, index_options = add_index_options(table_name, column_name, options) execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{index_columns})#{index_options}" @@ -745,7 +752,7 @@ 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) + options.assert_valid_keys(:unique, :order, :name, :where, :length, :internal, :using) index_type = options[:unique] ? "UNIQUE" : "" index_name = options[:name].to_s if options.key?(:name) |