From 447ad0f6e9ea1de92b71568322d6ea4d8b5c6f95 Mon Sep 17 00:00:00 2001 From: Dante Soares Date: Tue, 24 May 2022 16:32:10 -0500 Subject: [PATCH] Remove Stems that no longer have a Question --- db/migrate/20220523181437_fix_foreign_keys.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/db/migrate/20220523181437_fix_foreign_keys.rb b/db/migrate/20220523181437_fix_foreign_keys.rb index 45901c23..2c62a115 100644 --- a/db/migrate/20220523181437_fix_foreign_keys.rb +++ b/db/migrate/20220523181437_fix_foreign_keys.rb @@ -18,6 +18,10 @@ def change StemAnswer.where.not( Answer.where('"answers"."id" = "stem_answers"."answer_id"').arel.exists ).delete_all + + Stem.where.not( + Question.where('"questions"."id" = "stems"."question_id"').arel.exists + ).delete_all end end