How to deal with model generate error?

Today I follow with rails 4 guide to create the second model 'Comment', but I forgot the add the post as a reference,so I do like this: ide

1. I generate a error model named 'Comment' post

2. I found the error,so I do the action: rake db:rollback ui

3. I found I am a foolish,I roll back the first exist model(post model) migrate this

4. Then I do "rake db:migrate" again, then I caught a error: the comment table is exist. spa

So how to solve this issue? ci

it can not via rake db:rollback, then rake db:migrate to do,the error will be exist always,that because the migrate has been done,and the tables are in the db,so the way is to do like this: get

1. rake db:drop it

2. rake db:create io

3. rake db:migrate table

BUT if the project is not a exercise project, it is a business project,so we can not drop db,so like this, how should we do? do like this:

http://stackoverflow.com/questions/18961900/error-to-migrate-db-rails

Thanks,

Blues

相關文章
相關標籤/搜索