【发布时间】:2014-09-04 20:20:02
【问题描述】:
我在运行 db:reset 时遇到此错误
rake aborted!
ActiveRecord::StatementInvalid: PG::DependentObjectsStillExist: ERROR: cannot drop table seasons because other objects depend on it
DETAIL: constraint weeks_season_id_fk on table weeks depends on table seasons
HINT: Use DROP ... CASCADE to drop the dependent objects too.
: DROP TABLE "seasons"
我添加的最新迁移是...
class AddSeasonIdToWeek < ActiveRecord::Migration
def change
add_column :weeks, :season_id, :integer, null: false, index: true
end
end
和
class AddForeignKeySeasonsToWeeks < ActiveRecord::Migration
def change
change_table :weeks do |a|
a.foreign_key :seasons
end
end
end
我需要做什么才能克服这个错误?
【问题讨论】:
-
您是否使用外国人 gem 来允许外键迁移?
标签: ruby-on-rails migration rake