Ruby on rails 如何解决:SQLException:没有这样的表:位置:ALTER table";地点“;加上「;“用户id”;整数

Ruby on rails 如何解决:SQLException:没有这样的表:位置:ALTER table";地点“;加上「;“用户id”;整数,ruby-on-rails,ruby,postgresql,sqlite,Ruby On Rails,Ruby,Postgresql,Sqlite,我在rails上遇到了一些DB问题。运行rails db:migrate时,出现以下错误: add_column(:locations, :user_id, :integer) rake aborted! StandardError: An error has occurred, this and all later migrations canceled: SQLite3::SQLException: no such table: locations: ALTER TABLE "locati

我在rails上遇到了一些DB问题。运行
rails db:migrate
时,出现以下错误:

add_column(:locations, :user_id, :integer)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::SQLException: no such table: locations: ALTER TABLE "locations" ADD "user_id" integer

问题似乎是我有一个迁移,它试图将
:user_id
添加到表
:locations
,但该表不存在,因为我删除了它,因此它不在架构中。我如何解决这个问题?我一直认为删除迁移是个坏主意。

视情况而定。迁移是否创建并删除了
位置
?如果是这样,从时间上讲,失败的迁移是在这些迁移之间进行的吗?。如果答案是“是”,则不应删除它


另一方面,如果您在迁移失败之前手动或迁移删除了
位置,那么请将其删除,因为这对您的模式没有意义。

位置
是由
rails g model Location
创建的,但似乎没有迁移文件。当我试图从模式中删除该表时,可能是出于某种原因删除了它。如果我删除迁移,我是否只是手动删除文件?或者我应该使用什么命令?只需删除文件。