【发布时间】:2016-01-06 15:22:50
【问题描述】:
我决定不使用 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: 关系“tags”的列“taggings_count”不存在
ActiveRecord::StatementInvalid: PG::UndefinedColumn: 错误: 关系“tags”的列“taggings_count”不存在 : ALTER TABLE "tags" DROP "taggings_count"
PG::UndefinedColumn: 错误:关系的列“taggings_count” “标签”不存在
我从最近到最早一次运行它们。如果这些不运行,我该怎么办?
【问题讨论】:
-
向我们展示失败的迁移可能 ..uhhhm.. 有助于诊断。
-
def self.down remove_column :tags, :taggings_count end
-
如果您的数据库正在开发中,请尝试
rake db:migrate:reset,它将回滚所有迁移并从头开始迁移,以便您拥有一个没有任何数据的干净数据库!
标签: ruby-on-rails ruby postgresql activerecord