【发布时间】:2014-07-22 00:26:56
【问题描述】:
我在 Rails4 中运行以下内容:
$ bundle exec rake db:migrate
== 201405270646 AddAttachmentImageToPins:迁移 =========================== -- change_table(:pins) rake 中止! StandardError:发生错误,此迁移和所有后续迁移已取消:
SQLite3::SQLException: no such table: pin: ALTER TABLE "pins" ADD “image_file_name” varchar(255)c:/Sites/pinteresting/db/migrate/201405270646_add_attachment_im age_to_pins.rb:4:in
block in up' c:/Sites/pinteresting/db/migrate/201405270646_add_attachment_image_to_pins.rb:3: inup' c:in `migrate' 任务:TOP => db:migrate(查看完整跟踪 使用 --trace 运行任务)
我无法理解为什么会出现此错误。
这是我的 github:https://github.com/frankzk/pinteresting
感谢您的帮助
迁移文件:
class AddAttachmentImageToPins < ActiveRecord::Migration
def self.up
change_table :pins do |t|
t.attachment :image
end
end
def self.down
drop_attached_file :pins, :image
end
end
【问题讨论】:
-
你能发布你的迁移文件吗?
-
您是否删除了较旧的迁移文件?
-
@user2675613 我已经发帖了
-
我建议您先创建
rake db:drop,然后再创建rake db:create,然后再创建rake db:migrate。这将删除您的数据库并重新创建它并正确运行所有迁移(我希望如此)。告诉我们它是否有效。 -
@TamerShlash 它不起作用。运行 rake db:migrate 后,它向我显示了同样的错误
标签: ruby-on-rails rails-migrations