运行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
如何解决此错误需要做什么?
答案 0 :(得分:0)
尝试在rails 4中使用它:
rake db:rollback
两次
在较旧版本的rails中(可能是3及之前)
rake db:migrate:down
两次