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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user