Add tournament update functionality and enhance UI for tournament management
This commit introduces the ability to update tournament details, including name and date, in the backend and frontend. The new `updateTournament` method is added to the `tournamentController` and `tournamentService`, allowing for validation and error handling. The frontend `TournamentsView` is updated to include input fields for editing tournament details, with real-time updates reflected in the UI. Additionally, new CSS styles are introduced for improved layout and user interaction, enhancing the overall experience in tournament management.
This commit is contained in:
29
backend/migrations/add_name_to_tournament.sql
Normal file
29
backend/migrations/add_name_to_tournament.sql
Normal file
@@ -0,0 +1,29 @@
|
||||
-- Migration: Add name column to tournament table
|
||||
-- Date: 2025-01-13
|
||||
-- For MariaDB/MySQL
|
||||
|
||||
-- Add name column if it doesn't exist
|
||||
-- Check if column exists and add it if not
|
||||
SET @dbname = DATABASE();
|
||||
SET @tablename = 'tournament';
|
||||
SET @columnname = 'name';
|
||||
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, '` VARCHAR(255) NOT NULL DEFAULT "" AFTER `id`')
|
||||
));
|
||||
PREPARE alterIfNotExists FROM @preparedStatement;
|
||||
EXECUTE alterIfNotExists;
|
||||
DEALLOCATE PREPARE alterIfNotExists;
|
||||
|
||||
-- Update existing tournaments: set name to formatted date if name is empty
|
||||
UPDATE `tournament`
|
||||
SET `name` = DATE_FORMAT(`date`, '%d.%m.%Y')
|
||||
WHERE `name` = '' OR `name` IS NULL;
|
||||
|
||||
Reference in New Issue
Block a user