rake db:migrate is not working

为君一笑 提交于 2019-11-28 21:21:30

Try to rebuild your database structure(WARNING: all db-data will be lost):

rake db:drop:all
rake db:create:all
rake db:migrate

If you use Rails < 4.1, don't forget to prepare test database:

rake db:test:prepare

This is the easiest solution since you are working with tutorial. However in production or having important data in development you should take time to investigate the issue. In this case you most likely had created an empty migration, ran rake db:migrate, then added instructions to the migration, so you don't see a new field and further rake db:migrate does nothing. To resolve this issue you need to comment your change instructions, perform rake db:rollback, uncomment instructions and then rake db:migrate to apply instructions you missed.

I had the same issue as the initial question. $ bundle exec rake db:migrate wasn't adding remember_token to the .db and Latha Doddikadi's answer worked for me.

I did:

rake db:rollback

and then:

$ bundle exec rake db:migrate

which added the remember_token field to the database followed by:

bundle exec rspec spec/models/user_spec.rb

which passed.

Finished in 0.92841 seconds
21 examples, 0 failures

Roll back and then re run the migration it might work.

     rake db:rollback

And after rolling back re run your migrations again.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!