Implement tournament pairing functionality and enhance participant management
- Introduced new endpoints for managing tournament pairings, including creating, updating, and deleting pairings. - Updated the tournament service to handle pairing logic, ensuring validation for participants and preventing duplicate pairings. - Enhanced participant management by adding class-based checks for gender and age restrictions when adding participants. - Updated the tournament controller and routes to support the new pairing features and improved participant handling. - Added localization support for new UI elements related to pairings in the frontend, enhancing user experience.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
-- Migration: Geschlecht zu externen Turnierteilnehmern hinzufügen
|
||||
-- Datum: 2025-01-XX
|
||||
|
||||
ALTER TABLE `external_tournament_participant`
|
||||
ADD COLUMN `gender` ENUM('male', 'female', 'diverse', 'unknown') NULL DEFAULT 'unknown' AFTER `birth_date`;
|
||||
|
||||
|
||||
|
||||
8
backend/migrations/add_gender_to_tournament_class.sql
Normal file
8
backend/migrations/add_gender_to_tournament_class.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
-- Migration: Geschlecht zu Turnierklassen hinzufügen
|
||||
-- Datum: 2025-01-XX
|
||||
|
||||
ALTER TABLE `tournament_class`
|
||||
ADD COLUMN `gender` ENUM('male', 'female', 'mixed') NULL DEFAULT NULL AFTER `is_doubles`;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Migration: Add is_doubles column to tournament_class table
|
||||
-- Date: 2025-01-23
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
ALTER TABLE `tournament_class`
|
||||
ADD COLUMN `is_doubles` TINYINT(1) NOT NULL DEFAULT 0 AFTER `sort_order`;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
-- Migration: Geburtsjahr-Beschränkung zu Turnierklassen hinzufügen
|
||||
-- Datum: 2025-01-XX
|
||||
-- Beschreibung: Fügt max_birth_year Feld hinzu für "geboren im Jahr X oder früher" (<=)
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
SET @dbname = DATABASE();
|
||||
SET @tablename = 'tournament_class';
|
||||
SET @columnname = 'max_birth_year';
|
||||
|
||||
-- Check if column exists
|
||||
SET @column_exists = (
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE
|
||||
(TABLE_SCHEMA = @dbname)
|
||||
AND (TABLE_NAME = @tablename)
|
||||
AND (COLUMN_NAME = @columnname)
|
||||
);
|
||||
|
||||
-- Add column if it doesn't exist
|
||||
SET @sql = IF(@column_exists = 0,
|
||||
'ALTER TABLE `tournament_class` ADD COLUMN `max_birth_year` INT(11) NULL DEFAULT NULL AFTER `gender`',
|
||||
'SELECT 1 AS column_already_exists'
|
||||
);
|
||||
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
33
backend/migrations/create_tournament_pairing_table.sql
Normal file
33
backend/migrations/create_tournament_pairing_table.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- Migration: Create tournament_pairing table
|
||||
-- Date: 2025-01-23
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tournament_pairing` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`tournament_id` INT(11) NOT NULL,
|
||||
`class_id` INT(11) NOT NULL,
|
||||
`group_id` INT(11) NULL,
|
||||
`member1_id` INT(11) NULL,
|
||||
`external1_id` INT(11) NULL,
|
||||
`member2_id` INT(11) NULL,
|
||||
`external2_id` INT(11) NULL,
|
||||
`seeded` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`created_at` DATETIME NOT NULL,
|
||||
`updated_at` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tournament_id` (`tournament_id`),
|
||||
KEY `class_id` (`class_id`),
|
||||
KEY `group_id` (`group_id`),
|
||||
KEY `member1_id` (`member1_id`),
|
||||
KEY `member2_id` (`member2_id`),
|
||||
KEY `external1_id` (`external1_id`),
|
||||
KEY `external2_id` (`external2_id`),
|
||||
CONSTRAINT `tournament_pairing_ibfk_1` FOREIGN KEY (`tournament_id`) REFERENCES `tournament` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `tournament_pairing_ibfk_2` FOREIGN KEY (`class_id`) REFERENCES `tournament_class` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `tournament_pairing_ibfk_3` FOREIGN KEY (`group_id`) REFERENCES `tournament_group` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
-- Migration: Umbenennen von max_birth_year zu min_birth_year
|
||||
-- Datum: 2025-01-XX
|
||||
-- Beschreibung: Ändert die Logik von "geboren <= X" zu "geboren >= X"
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
SET @dbname = DATABASE();
|
||||
SET @tablename = 'tournament_class';
|
||||
SET @oldcolumnname = 'max_birth_year';
|
||||
SET @newcolumnname = 'min_birth_year';
|
||||
|
||||
-- Check if old column exists
|
||||
SET @old_column_exists = (
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE
|
||||
(TABLE_SCHEMA = @dbname)
|
||||
AND (TABLE_NAME = @tablename)
|
||||
AND (COLUMN_NAME = @oldcolumnname)
|
||||
);
|
||||
|
||||
-- Check if new column already exists
|
||||
SET @new_column_exists = (
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE
|
||||
(TABLE_SCHEMA = @dbname)
|
||||
AND (TABLE_NAME = @tablename)
|
||||
AND (COLUMN_NAME = @newcolumnname)
|
||||
);
|
||||
|
||||
-- Rename column if old exists and new doesn't
|
||||
SET @sql = IF(@old_column_exists > 0 AND @new_column_exists = 0,
|
||||
CONCAT('ALTER TABLE `', @tablename, '` CHANGE COLUMN `', @oldcolumnname, '` `', @newcolumnname, '` INT(11) NULL DEFAULT NULL AFTER `gender`'),
|
||||
IF(@new_column_exists > 0,
|
||||
'SELECT 1 AS column_already_renamed',
|
||||
'SELECT 1 AS old_column_not_found'
|
||||
)
|
||||
);
|
||||
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
Reference in New Issue
Block a user