How to Create Postgres Indexes Concurrently in ActiveRecord Migrations
By default, Postgres locks writes (but not reads) to a table while creating an index on it. That can result in unacceptable downtime during a production deploy. On a large table, indexing can take hours.
However, ActiveRecord 4 makes it easy to create Postgres indexes concurrently and avoid accidental downtime caused by long, write-blocking database indexing.