Implement external participant management and tournament class features
This commit enhances the tournament management system by introducing functionality for handling external participants and tournament classes. New methods are added to the `tournamentController` and `tournamentService` for adding, retrieving, updating, and removing external participants, as well as managing tournament classes. The backend models are updated to support these features, including new relationships and attributes. The frontend is also updated to allow users to manage external participants and classes, improving the overall user experience and interactivity in tournament management.
This commit is contained in:
22
backend/migrations/add_allows_external_to_tournament.sql
Normal file
22
backend/migrations/add_allows_external_to_tournament.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
-- Migration: Add 'allows_external' column to tournament table
|
||||
-- Date: 2025-01-15
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
SET @dbname = DATABASE();
|
||||
SET @tablename = 'tournament';
|
||||
SET @columnname = 'allows_external';
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE
|
||||
(TABLE_SCHEMA = @dbname)
|
||||
AND (TABLE_NAME = @tablename)
|
||||
AND (COLUMN_NAME = @columnname)
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
CONCAT('ALTER TABLE `', @tablename, '` ADD COLUMN `', @columnname, '` TINYINT(1) NOT NULL DEFAULT 0 AFTER `winning_sets`')
|
||||
));
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
-- Migration: Add 'class_id' column to external_tournament_participant table
|
||||
-- Date: 2025-01-15
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
SET @dbname = DATABASE();
|
||||
SET @tablename = 'external_tournament_participant';
|
||||
SET @columnname = 'class_id';
|
||||
|
||||
-- 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 `external_tournament_participant` ADD COLUMN `class_id` INT(11) NULL AFTER `seeded`',
|
||||
'SELECT 1 AS column_already_exists'
|
||||
);
|
||||
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
27
backend/migrations/add_class_id_to_tournament_group.sql
Normal file
27
backend/migrations/add_class_id_to_tournament_group.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
-- Migration: Add 'class_id' column to tournament_group table
|
||||
-- Date: 2025-01-15
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
SET @dbname = DATABASE();
|
||||
SET @tablename = 'tournament_group';
|
||||
SET @columnname = 'class_id';
|
||||
|
||||
-- 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_group` ADD COLUMN `class_id` INT(11) NULL AFTER `tournament_id`',
|
||||
'SELECT 1 AS column_already_exists'
|
||||
);
|
||||
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
27
backend/migrations/add_class_id_to_tournament_match.sql
Normal file
27
backend/migrations/add_class_id_to_tournament_match.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
-- Migration: Add 'class_id' column to tournament_match table
|
||||
-- Date: 2025-01-16
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
SET @dbname = DATABASE();
|
||||
SET @tablename = 'tournament_match';
|
||||
SET @columnname = 'class_id';
|
||||
|
||||
-- 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_match` ADD COLUMN `class_id` INT(11) NULL AFTER `group_id`',
|
||||
'SELECT 1 AS column_already_exists'
|
||||
);
|
||||
|
||||
PREPARE stmt FROM @sql;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
|
||||
22
backend/migrations/add_class_id_to_tournament_member.sql
Normal file
22
backend/migrations/add_class_id_to_tournament_member.sql
Normal file
@@ -0,0 +1,22 @@
|
||||
-- Migration: Add 'class_id' column to tournament_member table
|
||||
-- Date: 2025-01-15
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
SET @dbname = DATABASE();
|
||||
SET @tablename = 'tournament_member';
|
||||
SET @columnname = 'class_id';
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE
|
||||
(TABLE_SCHEMA = @dbname)
|
||||
AND (TABLE_NAME = @tablename)
|
||||
AND (COLUMN_NAME = @columnname)
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
CONCAT('ALTER TABLE `', @tablename, '` ADD COLUMN `', @columnname, '` INT(11) NULL AFTER `seeded`')
|
||||
));
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
-- Migration: Change 'ttr' column to 'birth_date' in external_tournament_participant table
|
||||
-- Date: 2025-01-15
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
SET @dbname = DATABASE();
|
||||
SET @tablename = 'external_tournament_participant';
|
||||
SET @oldcolumnname = 'ttr';
|
||||
SET @newcolumnname = 'birth_date';
|
||||
|
||||
-- Check if old column exists
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE
|
||||
(TABLE_SCHEMA = @dbname)
|
||||
AND (TABLE_NAME = @tablename)
|
||||
AND (COLUMN_NAME = @oldcolumnname)
|
||||
) > 0,
|
||||
CONCAT('ALTER TABLE `', @tablename, '` CHANGE COLUMN `', @oldcolumnname, '` `', @newcolumnname, '` VARCHAR(255) NULL AFTER `club`'),
|
||||
'SELECT 1'
|
||||
));
|
||||
PREPARE alterIfExists FROM @preparedStatement;
|
||||
EXECUTE alterIfExists;
|
||||
DEALLOCATE PREPARE alterIfExists;
|
||||
|
||||
-- If old column didn't exist, check if new column exists and add it if not
|
||||
SET @preparedStatement = (SELECT IF(
|
||||
(
|
||||
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE
|
||||
(TABLE_SCHEMA = @dbname)
|
||||
AND (TABLE_NAME = @tablename)
|
||||
AND (COLUMN_NAME = @newcolumnname)
|
||||
) > 0,
|
||||
'SELECT 1',
|
||||
CONCAT('ALTER TABLE `', @tablename, '` ADD COLUMN `', @newcolumnname, '` VARCHAR(255) NULL AFTER `club`')
|
||||
));
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
-- Migration: Create external_tournament_participant table
|
||||
-- Date: 2025-01-15
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `external_tournament_participant` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`tournament_id` INT(11) NOT NULL,
|
||||
`group_id` INT(11) NULL,
|
||||
`first_name` VARCHAR(255) NOT NULL,
|
||||
`last_name` VARCHAR(255) NOT NULL,
|
||||
`club` VARCHAR(255) NULL,
|
||||
`birth_date` VARCHAR(255) NULL,
|
||||
`seeded` TINYINT(1) NOT NULL DEFAULT 0,
|
||||
`created_at` DATETIME NOT NULL,
|
||||
`updated_at` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_tournament_id` (`tournament_id`),
|
||||
INDEX `idx_group_id` (`group_id`),
|
||||
CONSTRAINT `fk_external_participant_tournament` FOREIGN KEY (`tournament_id`) REFERENCES `tournament` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_external_participant_group` FOREIGN KEY (`group_id`) REFERENCES `tournament_group` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
16
backend/migrations/create_tournament_class_table.sql
Normal file
16
backend/migrations/create_tournament_class_table.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- Migration: Create tournament_class table
|
||||
-- Date: 2025-01-15
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tournament_class` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`tournament_id` INT(11) NOT NULL,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`sort_order` INT(11) NOT NULL DEFAULT 0,
|
||||
`created_at` DATETIME NOT NULL,
|
||||
`updated_at` DATETIME NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `tournament_id` (`tournament_id`),
|
||||
CONSTRAINT `tournament_class_ibfk_1` FOREIGN KEY (`tournament_id`) REFERENCES `tournament` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
Reference in New Issue
Block a user