fix(tournament): remove matches for participants before deletion

- Added logic to delete all matches associated with a participant before their removal from the tournament, ensuring data integrity and preventing orphaned match records.
This commit is contained in:
Torsten Schulz (local)
2026-01-31 00:08:25 +01:00
parent 75cc2df06b
commit d12b9daf87

View File

@@ -3380,6 +3380,16 @@ Ve // 2. Neues Turnier anlegen
if (!participant) {
throw new Error('Externer Teilnehmer nicht gefunden');
}
// Lösche alle Matches, in denen dieser Teilnehmer spielt
await TournamentMatch.destroy({
where: {
tournamentId,
[Op.or]: [
{ player1Id: participantId },
{ player2Id: participantId }
]
}
});
await participant.destroy();
}