zarathustra
zarathustra

Reputation: 2080

Does Rails index existing records when running an index migration?

When adding an index to an existing column in Rails:

add_index :users, :some_id

and then running the migrations:

rake db:migrate

Are all pre-existing records/columns automatically indexed? Database used is Postgres.

Upvotes: 1

Views: 346

Answers (1)

mrzasa
mrzasa

Reputation: 23317

Yes, it does. It calls postgres CREATE INDEX that creates an index and fills it with existing data.

Upvotes: 5

Related Questions