Delete options and answers before deleting question
This commit is contained in:
@@ -213,6 +213,11 @@ export async function upsertExercise(questionnaire, exerciseId) {
|
|||||||
if (deleted_at) {
|
if (deleted_at) {
|
||||||
// Delete from server only if this question exists in the database
|
// Delete from server only if this question exists in the database
|
||||||
if (!isNew(id)) {
|
if (!isNew(id)) {
|
||||||
|
await supabase.from('option').delete().match({ question_id: id });
|
||||||
|
await supabase
|
||||||
|
.from('question_answer')
|
||||||
|
.delete()
|
||||||
|
.match({ question_id: id });
|
||||||
const { error } = await supabase
|
const { error } = await supabase
|
||||||
.from('question')
|
.from('question')
|
||||||
.delete()
|
.delete()
|
||||||
@@ -222,8 +227,6 @@ export async function upsertExercise(questionnaire, exerciseId) {
|
|||||||
console.error('Cannot delete this question', error);
|
console.error('Cannot delete this question', error);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
await supabase.from('option').delete().match({ question_id: id });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip the remaining operation so we filter out this question from the new questions array
|
// Skip the remaining operation so we filter out this question from the new questions array
|
||||||
|
|||||||
Reference in New Issue
Block a user