Reputation: 1148
so when creating a concurrent index, the CONCURRENTLY does not get added into the CREATE INDEX of my structure.sql as I have it set to config.active_record.schema_format = :sql
in my config.application.rb
class IndexUsersOnDateOfBirth < ActiveRecord::Migration
disable_ddl_transaction!
def change
add_index :users, :date_of_birth, algorithm: :concurrently
end
end
gets listed in my structure.sql as
CREATE INDEX index_users_on_date_of_birth ON users USING btree (date_of_birth);
I would expect it to look like
CREATE INDEX CONCURRENTLY index_users_on_date_of_birth ON users USING btree (date_of_birth);
is this a known issue? how can I be sure when running the migration that it's actually running concurrently
Upvotes: 2
Views: 330
Reputation: 769
db/struture.sql
or db/schema.rb
is a reflection of current schema structure of the database, so it won't have information about the algorithm when adding the index (the algorithm is used in the migration process, irrelevant with the final state of schema).
About the question that "how can I be sure when running the migration that it's actually running concurrently"? I think the only thing you could know is from the output when running the migration:
$ rake db:migrate
== 20160616073441 AddIndextoUsers: migrating ==================================
-- add_index(:users, :age, {:algorithm=>:concurrently})
-> 0.0243s
== 20160616073441 AddIndextoUsers: migrated (0.0244s) =========================
ActiveRecord will raise an error when the algorithm option is not supported, eg. when your algorithm has a typo.
Upvotes: 2