本文介绍了rake db:migrate错误表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行 rake db:migrate ,并在控制台中收到错误。



似乎我正在创建一个已经存在的表,但我不知道如何删除旧表,或者重置db以开始新鲜。 / p>

我没有任何用户如此擦除或从新鲜开始不会是一个问题。


解决方案

如果您不介意删除数据,您可以运行

  rake db:drop 
rake d b:创建
rake db:migrate

,应该修复它。否则,您可以暂时注释掉部分内容,导致迁移中的更改(或向上)方法出现问题,然后运行迁移。迁移后,迁移将被移除。



执行此操作可以接受迁移是最新的。


I am trying to run rake db:migrate and am receiving an error in the console.

It seems as though I am creating a table that already exists, yet I don't know how to remove the old table, or reset the db to start fresh.

I don't have any users so erasing or starting from fresh won't be an issue.

解决方案

If you don't mind erasing data you can run

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

and that should fix it. Otherwise you can for the moment comment out the part of the content causing problems in the change (or up) method in your migration and then run the migrations. After the migration is run uncomment the migration.

Doing this tricks rails into accepting that the migrations are up to date.

这篇关于rake db:migrate错误表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 06:36