heroku run rake db:migrate error

半世苍凉 提交于 2019-12-02 07:33:56

It looks like the following is true:

  • 20120525005302_create_users.rb will attempt to create a users table in your database.
  • 20120611000411_devise_create_users.rb will also attempt to create a users table in the database.
  • Your database currently already has a users table in it, so the migration fails on the second migration.

To get the users table in your database to correspond properly to the 20120611000411_devise_create_users.rb migration, you can do one of two things:

  1. Roll back (or drop) the database, and then run the migrations again. (You can delete the 20120525005302_create_users.rb if it is empty.)
  2. Modify your 20120611000411_devise_create_users.rb migration to drop any existing users table before doing anything else.
  3. Modify your 20120611000411_devise_create_users.rb migration as follows:
    • Instead of creating a users table, modify the existing table.
    • Add and modify database components to correspond

Generally, if your application is in an "infant state," then re-creating the database tends to be a quick way to build the initial structure of an application. However if you already have important data in your users table, you'll want to keep that and proceed by modifying the 20120611000411_devise_create_users.rb migration to change the database non-destructively.

References

It looks like you already have table users (probably from create_users migration) that device_create_users is trying to recreate

You can modify your create_device_users migration to just add the fields that you need

Alternatively if its a brand new app with no users you can just drop and try re running all the migraions

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