I am new to rails. I made an error when generating a db migration. I was trying to add avatar to restaurants. However I instead tried to add avatar to users.
This is the wrong command I entered:
rails g migration add_avatar_to_user avatar:string
However users does not exist it should be restaurants, so it should have been:
rails g migration add_avatar_to_restaurant avatar:string
I tried to do rake db:migrate and then realized my error I got:
SQLite3::SQLException: no such table: users: ALTER TABLE "users" ADD "avatar" varchar
I read some answers on stack overflow and they just said to run the correct generate migration and it will fix it. So I did but it did not.
So then I tried doing a rake db:rollback, which removed restaurants (This is the one I actually want to keep).
However I can see in my db/migrate folder I still have the migration where I created restaurant, the correct migration for adding avatar to restaurants and the the incorrect migration as per the picture below.
So before I mess it up any more I am wondering whether if I just delete the incorrect migration from the tree and run a rake db:migrate whether that will fix it or is there something else I should be doing.
Thanks
Aucun commentaire:
Enregistrer un commentaire