Aaron
Aaron

Reputation: 14039

Does the `index` option on Rails column migrations work?

I can write a migration like:

class CreateFoos < ActiveRecord::Migration
  def change
    create_table :foos do |t|
      t.string :bar, index: true
    end
  end
end

According to the docs index: true should also create an index for the table on that column however I can see in schema.rb that it does not.

Is this a known bug or is it related to my setup? FWIW I'm on Rails 4.1.8 using Postgres and PostGIS.

This also doesn't work for the longer syntax of t.column :bar, :string, index: true though it does seem to work for t.belongs_to.

Upvotes: 2

Views: 356

Answers (1)

smathy
smathy

Reputation: 27971

So, confirmed, this does not work as advertised in 4.1.8 nor in 4.1.9, and yes, it's a bug.

The bug is fixed in 4.2.0 (and the 4.1 -> 4.2 upgrade is simple).

Upvotes: 4

Related Questions