无法回滚迁移

3

我创建了迁移:

class AddVisibleToStocks < ActiveRecord::Migration[5.2]
  def change
    add_column :stocks, :visible, :boolean
  end
end

我进行了迁移。一切都很好,但当我需要回滚时,我看到了错误:

rake db:rollback

== 20180404150630 AddVisibleToStocks: reverting ===============================
-- remove_column(:stocks, :visible, :boolean)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

SQLite3::ConstraintException: FOREIGN KEY constraint failed: DROP TABLE "stocks"

我的股票模型:

class Stock < ApplicationRecord
  belongs_to :category
  has_and_belongs_to_many :providers
end

接着我进行了另一次迁移,但立即将其回滚——结果还是一样。

出了什么问题?


请分享“Stock”模型中的代码。 - Ganesh
好的,我分享代码。 - Kim K
1个回答

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接