我正在尝试删除我的rails 4.1应用程序中postgresql列索引的唯一性。
最初的迁移包括:
add_index :customer_action_plan_objectives, :customer_action_plan_id,:unique => true, :name => "plan_id"我试过了
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但是我得到了一个错误:
Index name 'index_customer_action_plan_objectives_on_customer_action_plan_id' on table 'customer_action_plan_objectives' does not exist这是由":name => "plan_id"“还是其他原因引起的问题?我目前的解决方案来源于this question and answer。
发布于 2014-06-20 04:00:59
看起来“remove_index”方法正在尝试从您传递的参数派生索引名称。但是上面的名称传递了一个‘add_index’参数。尽管我还没有使用过这种方法,但文档http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/remove_index显示您可以将名称传递给remove_index。
https://stackoverflow.com/questions/23987632
复制相似问题