Please dont blindly report it as a duplicate question, I have clearly explained I have seen all these solutions, but doesnt make any sense to me as beginner, in the given answers code is there to write, but its not clearly given where to write these code, how to do this....etc This is my Customers table description in the Schema file of my project, now what I need to do is just to remove the index created bellow:
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
It may seems like a duplicate question, but in my point of few with all my search in internet lot of methods are given but none worked for me or the methods given doesn't give a correct guide line on where to run the solution code or how to write migration code how to generate migration if required....etc......
As a beginner I found all the solutions complicated to understand, can Anyone please help in doing this in a convenient and easy way ?
Your help is appreciated in advance...!
rails g migration RemoveIndexFromCustomers
Then edit the migration file:
# db/migrate/20151016082936_remove_index_from_customers.rb
class RemoveIndexFromCustomers < ActiveRecord::Migration
def change
remove_index :customers, :user_id
end
end
Note that the timestamp part of the file name will be different.
rake db:migrate