From 575bcc6fd4aa419e821db591fe434175a7600bee Mon Sep 17 00:00:00 2001 From: Ilya Simpson Date: Wed, 4 Mar 2026 06:46:34 +1300 Subject: [PATCH] Clean up orphaned answers. When switching from plain-text answers to inflection tables and vice versa, orphaned answers should now be removed. --- src/app/vocab/update-question/route.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/app/vocab/update-question/route.ts b/src/app/vocab/update-question/route.ts index 856d236..129a7ba 100644 --- a/src/app/vocab/update-question/route.ts +++ b/src/app/vocab/update-question/route.ts @@ -109,6 +109,10 @@ async function updateQuestionWithAnswers( transaction: t, }, ); + await InflectionAnswer.destroy({ + where: { questionId: id }, + transaction: t, + }); await processPlainAnswers( id, proposedMainAnswer, @@ -162,6 +166,10 @@ async function updateQuestionWithInflectionAnswers( transaction: t, }, ); + await Answer.destroy({ + where: { questionId: id }, + transaction: t, + }); await processInflectionAnswers( id, proposedInflectionAnswers,