-- Migration: Add match result fields to match table
-- Date: 2025-01-27
-- For MariaDB

-- Add myTischtennis meeting ID
ALTER TABLE `match` 
ADD COLUMN my_tischtennis_meeting_id VARCHAR(255) NULL UNIQUE COMMENT 'Meeting ID from myTischtennis (e.g. 15440488)';

-- Add home match points
ALTER TABLE `match` 
ADD COLUMN home_match_points INT DEFAULT 0 NULL COMMENT 'Match points won by home team';

-- Add guest match points
ALTER TABLE `match` 
ADD COLUMN guest_match_points INT DEFAULT 0 NULL COMMENT 'Match points won by guest team';

-- Add is_completed flag
ALTER TABLE `match` 
ADD COLUMN is_completed BOOLEAN NOT NULL DEFAULT FALSE COMMENT 'Whether the match is completed';

-- Add PDF URL
ALTER TABLE `match` 
ADD COLUMN pdf_url VARCHAR(512) NULL COMMENT 'PDF URL from myTischtennis';

-- Create indexes
CREATE INDEX idx_match_my_tischtennis_meeting_id ON `match`(my_tischtennis_meeting_id);
CREATE INDEX idx_match_is_completed ON `match`(is_completed);

