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:

1. I generate a error model named 'Comment'

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

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

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

So how to solve this issue?

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:

1. rake db:drop

2. rake db:create

3. rake db:migrate

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

你可能感兴趣的:(How to deal with model generate error?)