2014-03-30 46 views
4

我发现在我的模式中有两个“survey_id”列,这对我造成了一些问题。具体而言,我需要删除第二个索引,因为我不希望survey_id是唯一的。如何删除轨道中的索引

add_index "completions", ["survey_id"], name: "index_completions_on_survey_id" 
add_index "completions", ["survey_id"], name: "index_completions_on_survey_id_and_user_id", unique: true 

我已经试过

def change 
    remove_index "completions", ["survey_id"], name => "index_completions_on_survey_id_and_user_id" 
end 

def change 
    remove_index "completions", ["survey_id"], name: "index_completions_on_survey_id_and_user_id" 
end 

但无论是那些似乎工作。什么是此迁移删除索引的正确语法?我觉得这是基本的,我只是错过了一些愚蠢的东西。提前致谢!

回答

6

在删除索引时,不提供索引中的列。尝试:

remove_index "completions", name: "index_completions_on_survey_id_and_user_id" 
+0

这工作完美!谢谢! –