当迁移无法迁移时,您会怎么做?

时间:2016-01-06 06:30:19

标签: ruby-on-rails ruby postgresql activerecord

我决定不使用gem 'acts_as_taggable_on',但由于某些原因我无法撤消迁移。有5:

   ** ^ more migrations ^ **
   up     20151018064454  Acts as taggable on migration.acts as taggable on engine
   up     20151018064455  Add missing unique indices.acts as taggable on engine
   up     20151018064456  Add taggings counter cache to tags.acts as taggable on engine
  down    20151018064457  Add missing taggable index.acts as taggable on engine
  down    20151018064458  Change collation for tag names.acts as taggable on engine
  ** v more migrations v **

当我运行rake db:migrate:down VERSION=20151018064456时,我收到错误:

  

PG :: UndefinedColumn:ERROR:column" taggings_count"关系"标签"不存在

     

ActiveRecord :: StatementInvalid:PG :: UndefinedColumn:ERROR:column" taggings_count"关系"标签"不存在   :ALTER TABLE"标签" DROP" taggings_count"

     

PG :: UndefinedColumn:ERROR:column" taggings_count"关系   "标记"不存在

我从最近到最早一次运行一个。如果这些不能运行,我该怎么办?

1 个答案:

答案 0 :(得分:0)

您可以尝试这样:

http://timestamp.comodoca.com/rfc3161 会让你退步一步

然后

rake db:rollback

将回滚rake db:rollback STEP=n 次迁移,其中n是您要回滚的最近迁移次数。

希望这有帮助!