diff --git a/backend/services/tournamentService.js b/backend/services/tournamentService.js index 82e7694..4411bc8 100644 --- a/backend/services/tournamentService.js +++ b/backend/services/tournamentService.js @@ -695,13 +695,9 @@ class TournamentService { return JSON.parse(JSON.stringify(tournaments)); } - // 2. Neues Turnier anlegen (prüft Duplikat) + // 2. Neues Turnier anlegen async addTournament(userToken, clubId, tournamentName, date, winningSets, allowsExternal) { await checkAccess(userToken, clubId); - const existing = await Tournament.findOne({ where: { clubId, date } }); - if (existing) { - throw new Error('Ein Turnier mit diesem Datum existiert bereits'); - } const t = await Tournament.create({ name: tournamentName, date, @@ -726,10 +722,6 @@ class TournamentService { if (!ortTrimmed) { throw new Error('Ort für die Minimeisterschaft fehlt'); } - const existing = await Tournament.findOne({ where: { clubId, date } }); - if (existing) { - throw new Error('Ein Turnier mit diesem Datum existiert bereits'); - } const Y = Number(year); if (!Number.isFinite(Y) || Y < 2000 || Y > 2100) { throw new Error('Ungültiges Jahr für die Minimeisterschaft'); @@ -776,6 +768,10 @@ class TournamentService { }))); } catch (err) { await transaction.rollback(); + const msg = err?.message || String(err); + if (msg.includes('max_birth_year') || msg.includes('Unknown column')) { + throw new Error('Datenbank-Migration für Minimeisterschaften fehlt. Bitte die Migration 20260130_add_mini_championship_and_max_birth_year.sql ausführen.'); + } throw err; } }