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/test/cases/adapters/postgresql | |
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/test/cases/adapters/postgresql')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/active_schema_test.rb | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/active_schema_test.rb b/activerecord/test/cases/adapters/postgresql/active_schema_test.rb index ac36d0e835..16329689c0 100644 --- a/activerecord/test/cases/adapters/postgresql/active_schema_test.rb +++ b/activerecord/test/cases/adapters/postgresql/active_schema_test.rb @@ -29,18 +29,27 @@ class PostgresqlActiveSchemaTest < ActiveRecord::TestCase false end - expected = %(CREATE UNIQUE INDEX "index_people_on_last_name" ON "people" ("last_name") WHERE state = 'active') + expected = %(CREATE UNIQUE INDEX "index_people_on_last_name" ON "people" ("last_name") WHERE state = 'active') assert_equal expected, add_index(:people, :last_name, :unique => true, :where => "state = 'active'") + expected = %(CREATE INDEX CONCURRENTLY "index_people_on_last_name" ON "people" ("last_name")) + assert_equal expected, add_index(:people, :last_name, algorithm: :concurrently) + %w(gin gist hash btree).each do |type| - expected = %(CREATE INDEX "index_people_on_last_name" ON "people" USING #{type} ("last_name")) - assert_equal expected, add_index(:people, :last_name, :using => type) + expected = %(CREATE INDEX "index_people_on_last_name" ON "people" USING #{type} ("last_name")) + assert_equal expected, add_index(:people, :last_name, using: type) + + expected = %(CREATE INDEX CONCURRENTLY "index_people_on_last_name" ON "people" USING #{type} ("last_name")) + assert_equal expected, add_index(:people, :last_name, using: type, algorithm: :concurrently) end - expected = %(CREATE UNIQUE INDEX "index_people_on_last_name" ON "people" USING gist ("last_name")) + assert_raise ArgumentError do + add_index(:people, :last_name, algorithm: :copy) + end + expected = %(CREATE UNIQUE INDEX "index_people_on_last_name" ON "people" USING gist ("last_name")) assert_equal expected, add_index(:people, :last_name, :unique => true, :using => :gist) - expected = %(CREATE UNIQUE INDEX "index_people_on_last_name" ON "people" USING gist ("last_name") WHERE state = 'active') + expected = %(CREATE UNIQUE INDEX "index_people_on_last_name" ON "people" USING gist ("last_name") WHERE state = 'active') assert_equal expected, add_index(:people, :last_name, :unique => true, :where => "state = 'active'", :using => :gist) ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:remove_method, :index_name_exists?) |