The `column` method in ActiveRecord::ConnectionAdapters::TableDefinition supports adding the `index:` option. The documentation says: > Instantiates a new column for the table. See connection.add_column for > available options. > > Additional options are: > > :index - Create an index for the column. Can be either true or an > options hash. So basically the `connection.add_column` method silently ignores the `index:` option, and whenever we intended to create an index this way, we didn't. We're creating a new migration where we properly add the indexes that weren't added when we intended to. Thanks to the rubocop-rails team, who added this cop in version 2.11.0 and helped us notice this bug.
18 lines
645 B
Ruby
18 lines
645 B
Ruby
class AddMissingIndexes < ActiveRecord::Migration[5.2]
|
|
def change
|
|
add_index :comments, :confidence_score
|
|
add_index :users, :gender
|
|
add_index :users, :date_of_birth
|
|
add_index :budget_ballot_lines, :budget_id
|
|
add_index :budget_ballot_lines, :group_id
|
|
add_index :budget_ballot_lines, :heading_id
|
|
add_index :budget_investments, :budget_id
|
|
add_index :budget_investments, :group_id
|
|
add_index :budget_investments, :selected
|
|
add_index :polls, :geozone_restricted
|
|
add_index :failed_census_calls, :poll_officer_id
|
|
add_index :budget_investments, :incompatible
|
|
add_index :proposals, :selected
|
|
end
|
|
end
|