Add deleting session durations when deleting families

For the automatic deletion, they were always already deleted.
However, for manual deletion, this is required.
This commit is contained in:
Jonas Lochmann 2023-04-03 02:00:00 +02:00
parent 73465ebe6e
commit dc5e2baebd
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36

View file

@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * 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 * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@ -79,6 +79,16 @@ export async function deleteFamilies ({ database, familiyIds }: {
transaction transaction
}) })
// session durations
await database.sessionDuration.destroy({
where: {
familyId: {
[Sequelize.Op.in]: familiyIds
}
},
transaction
})
// user // user
await database.user.destroy({ await database.user.destroy({
where: { where: {