Skip to content

add_column ignores index: true #20400

Description

@collimarco

Using Rails 4.2.0 the index: true part in the following statement is completely ignored:

add_column :my_table, :my_column, :boolean, index: true

This happens for any type of column (e.g. boolean, string).

To reproduce this issue just create a table:

class CreateExamples < ActiveRecord::Migration
  def change
    create_table :examples
  end
end

Then add:

class AddSomethingToExamples < ActiveRecord::Migration
  def change
    add_column :examples, :something, :string, index: true
  end
end

Run the migrations. Then check schema.rbor directly the database and you won't find any index.

The documentation says:

See ActiveRecord::ConnectionAdapters::TableDefinition#column for details of the options you can use.

:index - Create an index for the column. Can be either true or an options hash.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions