From dc5e2baebd2ac53675c6ce79851c6ac63e172140 Mon Sep 17 00:00:00 2001 From: Jonas Lochmann Date: Mon, 3 Apr 2023 02:00:00 +0200 Subject: [PATCH] Add deleting session durations when deleting families For the automatic deletion, they were always already deleted. However, for manual deletion, this is required. --- src/function/cleanup/delete-families.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/function/cleanup/delete-families.ts b/src/function/cleanup/delete-families.ts index 514a553..b5856a6 100644 --- a/src/function/cleanup/delete-families.ts +++ b/src/function/cleanup/delete-families.ts @@ -1,6 +1,6 @@ /* * server component for the TimeLimit App - * Copyright (C) 2019 - 2022 Jonas Lochmann + * Copyright (C) 2019 - 2023 Jonas Lochmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -79,6 +79,16 @@ export async function deleteFamilies ({ database, familiyIds }: { transaction }) + // session durations + await database.sessionDuration.destroy({ + where: { + familyId: { + [Sequelize.Op.in]: familiyIds + } + }, + transaction + }) + // user await database.user.destroy({ where: {