Duplicate column name error when running migration

隐身守侯 提交于 2019-12-03 14:04:31

That happens if you migrations are not in sync with the database schema. This could happen if

  • you modified the database schema "by hand"
  • you changed a migration file being run
  • migrations have not been updated in the schema_migrations table

If you are not relying on the data in the database, a rake db:reset would re-run all migrations from scratch. Otherwise you have to make the conflicting migration recognized as already-run by adding to the schema_migrations table.

See RailsGuides of migrations as well.

I've also solved this problem by logging into the heroku database, and then dropping only the offending column. I think this is a less-destructive solution.

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