0

I am trying to remove the uniqueness off a postgresql column index in my rails 4.1 app.

The original migration included:

add_index :customer_action_plan_objectives, :customer_action_plan_id,:unique => true, :name => "plan_id"

I have tried

class ChangeIndexUniquenessCustomerActionPlanObjectives < ActiveRecord::Migration
  def change
    remove_index :customer_action_plan_objectives, :customer_action_plan_id
    add_index :customer_action_plan_objectives, :customer_action_plan_id, :name => "plan_id"
  end
end

But I am getting an error:

Index name 'index_customer_action_plan_objectives_on_customer_action_plan_id' on table 'customer_action_plan_objectives' does not exist

Is this an issue caused by ":name => "plan_id"" or something else? My current solution has been sourced form this question and answer.

Community
  • 1
  • 1
Jay Killeen
  • 2,832
  • 6
  • 39
  • 66

1 Answers1

0

Looks like the 'remove_index' method is trying to derive the index name from the parameters you are passing. But the add_index above that is passing a 'name' parameter. Thought I haven't used this method, the documentation http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/remove_index shows that you can pass name into the remove_index.

cwise
  • 1
  • 1