删除 Table 中的索引 Rails 4 使用 PL-SQL

Removing A Table Index In Rails 4 Using PL-SQL

请不要盲目地将其报告为重复问题,我已经清楚地解释了我已经看到了所有这些解决方案,但对我这个初学者来说没有任何意义,在给定的答案中代码是可以写的,但不是很清楚给定在哪里编写这些代码,如何做到这一点......等 这是我的项目架构文件中的客户 table 描述,现在我需要做的只是删除下面创建的索引:

add_index "customers", ["user_id"], name: "index_customers_on_user_id", using: :btree

create_table "customers", force: true do |t|
    t.string   "firstname"
    t.string   "lastname"
    t.string   "email"
    t.string   "phoneno"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "middlename"
    t.string   "salute"
    t.integer  "user_id"
    t.integer  "creater_id"
    t.string   "sale_type"
    t.integer  "referral_id"
  end

  add_index "customers", ["user_id"], name: "index_customers_on_user_id", using: :btree

这似乎是一个重复的问题,但就我在互联网上的所有搜索而言,给出了很多方法,但 none 对我有用,或者给出的方法没有给出正确的指导关于 运行 解决方案代码或如何编写迁移代码的行 如何在需要时生成迁移......等等......

作为一个初学者,我发现所有的解决方案都很难理解,请任何人帮助以方便和简单的方式做到这一点?

提前感谢您的帮助...!

rails g migration RemoveIndexFromCustomers

然后编辑迁移文件:

# db/migrate/20151016082936_remove_index_from_customers.rb
class RemoveIndexFromCustomers < ActiveRecord::Migration
  def change
    remove_index :customers, :user_id
  end
end

请注意,文件名的时间戳部分会有所不同。

rake db:migrate