CREATE TABLE IF NOT EXISTS `friendly_match` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `club_id` INT NOT NULL,
  `date` DATE NOT NULL,
  `time` TIME NULL,
  `home_team_name` VARCHAR(255) NOT NULL,
  `guest_team_name` VARCHAR(255) NOT NULL,
  `location_name` VARCHAR(255) NULL,
  `location_address` VARCHAR(255) NULL,
  `location_city` VARCHAR(255) NULL,
  `location_zip` VARCHAR(32) NULL,
  `match_system` VARCHAR(120) NOT NULL DEFAULT 'Braunschweiger System',
  `singles_count` INT NOT NULL DEFAULT 12,
  `doubles_count` INT NOT NULL DEFAULT 4,
  `winning_sets` INT NOT NULL DEFAULT 3,
  `home_match_points` INT NOT NULL DEFAULT 0,
  `guest_match_points` INT NOT NULL DEFAULT 0,
  `is_completed` TINYINT(1) NOT NULL DEFAULT 0,
  `home_participants` JSON NULL,
  `guest_participants` JSON NULL,
  `result_details` JSON NULL,
  `players_ready` JSON NULL,
  `players_planned` JSON NULL,
  `players_played` JSON NULL,
  `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_friendly_match_club_date` (`club_id`, `date`),
  KEY `idx_friendly_match_completed` (`club_id`, `is_completed`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
