-- --------------------------------------------------------
-- Server OS:                    debian-linux-gnu
-- HeidiSQL Version:             12.10.0.7000
-- --------------------------------------------------------



-- Dumping database structure for gcdm_global
CREATE DATABASE IF NOT EXISTS `gcdm_global` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci */;
USE `gcdm_global`;

-- Dumping structure for table gcdm_global.competitive_seasons
CREATE TABLE IF NOT EXISTS `competitive_seasons` (
  `season_id` int(11) NOT NULL AUTO_INCREMENT,
  `season_name` varchar(64) NOT NULL,
  `start_date` datetime NOT NULL,
  `end_date` datetime NOT NULL,
  `is_active` tinyint(1) DEFAULT 0,
  `rewards_distributed` tinyint(1) DEFAULT 0,
  `created_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`season_id`),
  KEY `idx_season_active` (`is_active`,`start_date`,`end_date`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

-- Dumping data for table gcdm_global.competitive_seasons: ~0 rows (approximately)
INSERT INTO `competitive_seasons` (`season_id`, `season_name`, `start_date`, `end_date`, `is_active`, `rewards_distributed`, `created_at`) VALUES
	(1, 'Season 1', '2025-09-09 10:13:59', '2025-12-09 10:13:59', 1, 0, '2025-09-09 10:13:59');

-- Dumping structure for table gcdm_global.matches
CREATE TABLE IF NOT EXISTS `matches` (
  `match_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `game_mode` varchar(32) NOT NULL DEFAULT 'ranked_5v5',
  `status` enum('preparing','ready','active','completed','cancelled','archived') DEFAULT 'preparing',
  `max_duration` int(11) DEFAULT 60,
  `created_at` datetime DEFAULT current_timestamp(),
  `started_at` datetime DEFAULT NULL,
  `ready_at` datetime DEFAULT NULL,
  `ended_at` datetime DEFAULT NULL,
  `team_a_size` int(11) DEFAULT 5,
  `team_b_size` int(11) DEFAULT 5,
  `mmr_average` int(11) DEFAULT 1200,
  `mmr_range_min` int(11) DEFAULT NULL,
  `mmr_range_max` int(11) DEFAULT NULL,
  `winning_team` char(1) DEFAULT NULL,
  `war_score_team_a` int(11) DEFAULT 0,
  `war_score_team_b` int(11) DEFAULT 0,
  PRIMARY KEY (`match_id`),
  KEY `idx_status` (`status`),
  KEY `idx_created` (`created_at`),
  KEY `idx_game_mode` (`game_mode`),
  KEY `idx_matches_status_created` (`status`,`created_at`),
  KEY `idx_matches_status_started` (`status`,`started_at`),
  KEY `idx_matches_ready_at` (`ready_at`)
) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

-- Dumping data for table gcdm_global.matches: ~43 rows (approximately)
INSERT INTO `matches` (`match_id`, `game_mode`, `status`, `max_duration`, `created_at`, `started_at`, `ready_at`, `ended_at`, `team_a_size`, `team_b_size`, `mmr_average`, `mmr_range_min`, `mmr_range_max`, `winning_team`, `war_score_team_a`, `war_score_team_b`) VALUES
	(5, 'ranked_5v5', 'completed', 5, '2025-09-11 13:26:10', '2025-09-11 13:26:10', NULL, '2025-09-11 17:18:50', 1, 1, 1200, NULL, NULL, 'A', 0, 0),
	(8, 'ranked_5v5', 'completed', 5, '2025-09-11 17:44:56', '2025-09-11 17:44:56', NULL, '2025-09-12 07:31:46', 1, 1, 1200, NULL, NULL, 'B', 0, 0),
	(9, 'ranked_5v5', 'completed', 60, '2025-09-12 20:15:55', '2025-09-12 20:15:55', NULL, '2025-09-12 20:15:55', 1, 1, 1200, NULL, NULL, '', 0, 0),
	(10, 'ranked_5v5', 'completed', 60, '2025-09-12 20:25:01', '2025-09-12 20:27:46', NULL, '2025-09-12 20:28:01', 1, 1, 1200, NULL, NULL, '', 0, 0),
	(11, 'ranked_5v5', 'completed', 60, '2025-09-12 21:01:01', '2025-09-12 22:00:42', '2025-09-12 21:01:21', '2025-09-11 23:01:35', 1, 1, 1200, NULL, NULL, 'A', 0, 0),
	(12, 'ranked_5v5', 'completed', 60, '2025-09-12 22:07:01', NULL, '2025-09-12 22:07:22', NULL, 1, 1, 1200, NULL, NULL, NULL, 0, 0),
	(13, 'ranked_5v5', 'archived', 60, '2025-09-13 12:49:01', '2025-09-13 12:16:18', '2025-09-13 12:49:19', '2025-09-13 13:17:01', 1, 1, 1200, NULL, NULL, 'A', 1500, 1500),
	(14, 'ranked_5v5', 'archived', 60, '2025-09-15 15:25:01', '2025-09-15 15:42:01', '2025-09-15 15:25:21', '2025-09-15 17:00:02', 1, 1, 1208, NULL, NULL, 'B', 1200, 1500),
	(15, 'ranked_5v5', 'archived', 5, '2025-09-15 17:07:01', '2025-09-15 17:08:01', '2025-09-15 17:07:14', '2025-09-15 17:13:01', 1, 1, 1208, NULL, NULL, 'A', 1216, 1200),
	(16, 'ranked_5v5', 'archived', 5, '2025-09-15 17:17:01', '2025-09-15 17:26:01', '2025-09-15 17:25:05', '2025-09-15 17:31:01', 1, 1, 1208, NULL, NULL, 'A', 1232, 1184),
	(17, 'ranked_5v5', 'archived', 10, '2025-09-15 17:35:01', '2025-09-15 17:36:01', '2025-09-15 17:35:10', '2025-09-15 17:46:01', 1, 1, 1208, NULL, NULL, 'B', 1247, 1500),
	(19, 'ranked_5v5', 'archived', 10, '2025-09-15 17:55:01', '2025-09-15 17:56:01', '2025-09-15 17:55:12', '2025-09-15 18:06:01', 1, 1, 1208, NULL, NULL, 'A', 1229, 1187),
	(20, 'ranked_5v5', 'archived', 10, '2025-09-15 18:12:01', '2025-09-15 18:13:01', '2025-09-15 18:12:13', '2025-09-15 18:23:01', 1, 1, 1208, NULL, NULL, 'A', 1244, 1172),
	(21, 'ranked_5v5', 'archived', 10, '2025-09-15 19:48:01', '2025-09-15 19:49:01', '2025-09-15 19:48:19', '2025-09-15 19:59:01', 1, 1, 1171, NULL, NULL, 'A', 1184, 1158),
	(22, 'ranked_5v5', 'archived', 10, '2025-09-15 20:01:01', '2025-09-15 20:02:01', '2025-09-15 20:01:16', '2025-09-15 20:12:01', 1, 1, 1171, NULL, NULL, 'A', 1199, 1143),
	(63, 'ranked_5v5', 'cancelled', 10, '2025-09-17 13:25:02', NULL, NULL, '2025-09-17 13:29:19', 1, 1, 1221, NULL, NULL, NULL, 0, 0),
	(64, 'ranked_5v5', 'cancelled', 10, '2025-09-17 13:26:02', NULL, NULL, '2025-09-17 13:30:19', 1, 1, 1221, NULL, NULL, NULL, 0, 0),
	(65, 'ranked_5v5', 'cancelled', 10, '2025-09-17 13:27:01', NULL, NULL, '2025-09-17 13:31:19', 1, 1, 1221, NULL, NULL, NULL, 0, 0),
	(66, 'ranked_5v5', 'cancelled', 10, '2025-09-17 13:28:01', NULL, NULL, '2025-09-17 13:32:19', 1, 1, 1221, NULL, NULL, NULL, 0, 0),
	(67, 'ranked_5v5', 'cancelled', 10, '2025-09-17 13:29:02', NULL, NULL, '2025-09-17 13:33:19', 1, 1, 1221, NULL, NULL, NULL, 0, 0),
	(68, 'ranked_5v5', 'cancelled', 10, '2025-09-17 13:30:01', NULL, NULL, '2025-09-17 13:34:18', 1, 1, 1221, NULL, NULL, NULL, 0, 0),
	(69, 'ranked_5v5', 'cancelled', 10, '2025-09-17 13:31:01', NULL, NULL, '2025-09-17 13:35:18', 1, 1, 1221, NULL, NULL, NULL, 0, 0),
	(70, 'ranked_5v5', 'cancelled', 10, '2025-09-17 13:32:01', NULL, NULL, '2025-09-17 13:36:18', 1, 1, 1221, NULL, NULL, NULL, 0, 0),
	(71, 'ranked_5v5', 'cancelled', 10, '2025-09-17 13:33:01', NULL, NULL, '2025-09-17 13:37:18', 1, 1, 1221, NULL, NULL, NULL, 0, 0),
	(72, 'ranked_5v5', 'cancelled', 10, '2025-09-17 13:34:01', NULL, NULL, '2025-09-17 13:38:18', 1, 1, 1221, NULL, NULL, NULL, 0, 0),
	(73, 'ranked_5v5', 'archived', 10, '2025-09-17 13:37:01', '2025-09-17 13:38:01', '2025-09-17 13:37:13', '2025-09-17 13:48:01', 1, 1, 1221, NULL, NULL, 'A', 1500, 1500),
	(74, 'ranked_5v5', 'archived', 10, '2025-09-17 13:52:01', '2025-09-17 13:55:01', '2025-09-17 13:52:22', '2025-09-17 14:05:01', 1, 1, 1221, NULL, NULL, 'B', 2004, 6338),
	(75, 'ranked_5v5', 'archived', 3, '2025-09-17 14:21:01', '2025-09-17 14:37:01', '2025-09-17 14:21:13', '2025-09-17 14:42:01', 1, 1, 1221, NULL, NULL, '', 0, 0),
	(76, 'ranked_5v5', 'archived', 10, '2025-09-17 14:43:01', '2025-09-17 14:46:01', '2025-09-17 14:43:09', '2025-09-17 14:56:01', 1, 1, 1221, NULL, NULL, 'B', 0, 25),
	(77, 'ranked_5v5', 'archived', 10, '2025-09-17 15:55:01', '2025-09-17 15:52:01', '2025-09-17 15:55:10', '2025-09-17 16:04:01', 1, 1, 1221, NULL, NULL, 'B', 15, 25),
	(78, 'ranked_5v5', 'archived', 10, '2025-09-17 16:33:01', '2025-09-17 17:36:01', '2025-09-17 16:33:23', '2025-09-17 17:58:01', 1, 1, 1221, NULL, NULL, '', 0, 0),
	(79, 'ranked_5v5', 'archived', 10, '2025-09-17 18:21:01', '2025-09-17 18:24:01', '2025-09-17 18:21:08', '2025-09-17 18:34:01', 1, 1, 1221, NULL, NULL, '', 0, 0),
	(80, 'ranked_5v5', 'archived', 10, '2025-09-17 18:38:01', '2025-09-17 18:41:01', '2025-09-17 18:38:15', '2025-09-17 18:51:01', 1, 1, 1221, NULL, NULL, '', 0, 0),
	(81, 'ranked_5v5', 'archived', 10, '2025-09-17 18:56:01', '2025-09-17 18:59:01', '2025-09-17 18:56:10', '2025-09-17 19:09:02', 1, 1, 1221, NULL, NULL, '', 0, 0),
	(82, 'ranked_5v5', 'archived', 10, '2025-09-17 19:12:01', '2025-09-17 19:17:01', '2025-09-17 19:12:08', '2025-09-17 19:27:01', 1, 1, 1221, NULL, NULL, '', 0, 0),
	(83, 'ranked_5v5', 'archived', 10, '2025-09-17 19:57:01', '2025-09-17 19:57:27', '2025-09-17 19:57:17', '2025-09-17 20:08:01', 1, 1, 1221, NULL, NULL, 'A', 50, 0),
	(84, 'ranked_5v5', 'archived', 10, '2025-09-18 11:53:01', '2025-09-18 11:54:07', '2025-09-18 11:53:57', '2025-09-18 12:05:01', 1, 1, 1219, NULL, NULL, '', 0, 0),
	(85, 'ranked_5v5', 'archived', 10, '2025-09-18 12:12:01', '2025-09-18 12:12:24', '2025-09-18 12:12:14', '2025-09-18 12:23:01', 1, 1, 1219, NULL, NULL, '', 0, 0),
	(86, 'ranked_5v5', 'archived', 10, '2025-09-18 12:45:01', '2025-09-18 12:45:20', '2025-09-18 12:45:10', '2025-09-18 12:56:01', 1, 1, 1219, NULL, NULL, '', 0, 0),
	(87, 'ranked_5v5', 'archived', 10, '2025-09-18 13:11:01', '2025-09-18 13:38:35', '2025-09-18 13:11:25', '2025-09-18 13:49:01', 1, 1, 1218, NULL, NULL, 'B', 0, 50),
	(88, 'ranked_5v5', 'archived', 10, '2025-09-18 14:30:01', '2025-09-18 14:30:34', '2025-09-18 14:30:24', '2025-09-18 14:41:01', 1, 1, 1213, NULL, NULL, '', 0, 0),
	(89, 'ranked_5v5', 'completed', 10, '2025-09-18 16:51:51', '2025-09-18 16:52:59', '2025-09-18 16:52:29', '2025-09-18 17:03:01', 2, 1, 1228, NULL, NULL, '', 0, 0),
	(90, 'ranked_5v5', 'completed', 10, '2025-09-18 17:20:41', '2025-09-18 17:51:33', '2025-09-18 17:21:03', '2025-09-18 18:01:41', 2, 2, 1221, NULL, NULL, 'B', 0, 25),
	(91, 'ranked_2v2', 'active', 30, '2025-09-18 20:33:11', '2025-09-18 20:33:51', '2025-09-18 20:33:21', NULL, 1, 1, 1200, NULL, NULL, NULL, 0, 0);

-- Dumping structure for table gcdm_global.matchmaking_queue
CREATE TABLE IF NOT EXISTS `matchmaking_queue` (
  `queue_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `global_account_id` int(11) NOT NULL,
  `game_mode` varchar(32) NOT NULL DEFAULT 'ranked_5v5',
  `mmr_snapshot` int(11) NOT NULL,
  `enqueued_at` datetime DEFAULT current_timestamp(),
  `status` enum('queued','matched','expired','cancelled','completed') DEFAULT 'queued',
  `match_id` bigint(20) DEFAULT NULL,
  `team_assignment` int(11) DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  PRIMARY KEY (`queue_id`),
  KEY `idx_queue_active` (`game_mode`,`status`,`enqueued_at`),
  KEY `idx_queue_mmr` (`game_mode`,`status`,`mmr_snapshot`),
  KEY `idx_account_queue` (`global_account_id`,`status`),
  CONSTRAINT `matchmaking_queue_ibfk_1` FOREIGN KEY (`global_account_id`) REFERENCES `global_account` (`account_id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=97 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

-- Dumping data for table gcdm_global.matchmaking_queue: ~61 rows (approximately)
INSERT INTO `matchmaking_queue` (`queue_id`, `global_account_id`, `game_mode`, `mmr_snapshot`, `enqueued_at`, `status`, `match_id`, `team_assignment`, `updated_at`) VALUES
	(22, 8, 'ranked_5v5', 1216, '2025-09-15 17:06:53', 'completed', 15, 1, '2025-09-15 17:13:01'),
	(23, 8, 'ranked_5v5', 1232, '2025-09-15 17:16:23', 'completed', 16, 1, '2025-09-15 17:31:01'),
	(24, 7, 'ranked_5v5', 1184, '2025-09-15 17:16:31', 'completed', 16, 2, '2025-09-15 17:31:01'),
	(25, 7, 'ranked_5v5', 1169, '2025-09-15 17:33:43', 'completed', 17, 2, '2025-09-15 17:46:01'),
	(26, 8, 'ranked_5v5', 1247, '2025-09-15 17:34:21', 'completed', 17, 1, '2025-09-15 17:46:01'),
	(27, 7, 'ranked_5v5', 1187, '2025-09-15 17:53:16', 'completed', 19, 2, '2025-09-15 18:06:01'),
	(28, 8, 'ranked_5v5', 1229, '2025-09-15 17:53:26', 'completed', 19, 1, '2025-09-15 18:06:01'),
	(29, 7, 'ranked_5v5', 1172, '2025-09-15 18:11:09', 'completed', 20, 2, '2025-09-15 18:23:01'),
	(30, 8, 'ranked_5v5', 1244, '2025-09-15 18:11:14', 'completed', 20, 1, '2025-09-15 18:23:01'),
	(31, 7, 'ranked_5v5', 1158, '2025-09-15 19:47:19', 'completed', 21, 2, '2025-09-15 19:59:01'),
	(32, 6, 'ranked_5v5', 1184, '2025-09-15 19:47:46', 'completed', 21, 1, '2025-09-15 19:59:01'),
	(33, 7, 'ranked_5v5', 1143, '2025-09-15 19:59:51', 'completed', 22, 2, '2025-09-15 20:12:01'),
	(34, 6, 'ranked_5v5', 1199, '2025-09-15 20:00:06', 'completed', 22, 1, '2025-09-15 20:12:01'),
	(35, 7, 'ranked_5v5', 1128, '2025-09-15 20:14:37', 'cancelled', NULL, NULL, NULL),
	(36, 6, 'ranked_5v5', 1214, '2025-09-15 20:15:04', 'cancelled', NULL, NULL, NULL),
	(37, 6, 'ranked_5v5', 1214, '2025-09-15 20:23:59', 'cancelled', NULL, NULL, NULL),
	(38, 7, 'ranked_5v5', 1128, '2025-09-15 20:24:32', 'cancelled', NULL, NULL, NULL),
	(41, 7, 'ranked_5v5', 1128, '2025-09-17 09:54:27', 'cancelled', NULL, NULL, NULL),
	(44, 6, 'ranked_5v5', 1214, '2025-09-17 12:19:10', 'cancelled', NULL, NULL, NULL),
	(45, 7, 'ranked_5v5', 1228, '2025-09-17 12:19:11', 'cancelled', NULL, NULL, NULL),
	(52, 7, 'ranked_5v5', 1228, '2025-09-17 13:36:35', 'completed', 73, 1, '2025-09-17 13:48:01'),
	(53, 6, 'ranked_5v5', 1214, '2025-09-17 13:36:39', 'completed', 73, 2, '2025-09-17 13:48:01'),
	(54, 7, 'ranked_5v5', 1244, '2025-09-17 13:51:15', 'completed', 74, 1, '2025-09-17 14:05:01'),
	(55, 6, 'ranked_5v5', 1198, '2025-09-17 13:51:24', 'completed', 74, 2, '2025-09-17 14:05:01'),
	(56, 7, 'ranked_5v5', 1227, '2025-09-17 14:20:44', 'completed', 75, 1, '2025-09-17 14:42:01'),
	(57, 6, 'ranked_5v5', 1215, '2025-09-17 14:20:49', 'completed', 75, 2, '2025-09-17 14:42:01'),
	(58, 7, 'ranked_5v5', 1227, '2025-09-17 14:42:26', 'completed', 76, 1, '2025-09-17 14:56:01'),
	(59, 6, 'ranked_5v5', 1215, '2025-09-17 14:42:31', 'completed', 76, 2, '2025-09-17 14:56:01'),
	(60, 7, 'ranked_5v5', 1211, '2025-09-17 15:54:03', 'completed', 77, 2, '2025-09-17 16:04:01'),
	(61, 6, 'ranked_5v5', 1231, '2025-09-17 15:54:07', 'completed', 77, 1, '2025-09-17 16:04:01'),
	(62, 7, 'ranked_5v5', 1227, '2025-09-17 16:31:38', 'completed', 78, 1, '2025-09-17 17:58:01'),
	(63, 6, 'ranked_5v5', 1215, '2025-09-17 16:32:47', 'completed', 78, 2, '2025-09-17 17:58:01'),
	(64, 7, 'ranked_5v5', 1227, '2025-09-17 18:20:40', 'completed', 79, 1, '2025-09-17 18:34:01'),
	(65, 6, 'ranked_5v5', 1215, '2025-09-17 18:21:00', 'completed', 79, 2, '2025-09-17 18:34:01'),
	(66, 7, 'ranked_5v5', 1227, '2025-09-17 18:37:36', 'completed', 80, 1, '2025-09-17 18:51:01'),
	(67, 6, 'ranked_5v5', 1215, '2025-09-17 18:37:45', 'completed', 80, 2, '2025-09-17 18:51:01'),
	(68, 7, 'ranked_5v5', 1227, '2025-09-17 18:55:06', 'completed', 81, 1, '2025-09-17 19:09:02'),
	(69, 6, 'ranked_5v5', 1215, '2025-09-17 18:55:10', 'completed', 81, 2, '2025-09-17 19:09:02'),
	(70, 7, 'ranked_5v5', 1227, '2025-09-17 19:11:41', 'completed', 82, 1, '2025-09-17 19:27:01'),
	(71, 6, 'ranked_5v5', 1215, '2025-09-17 19:11:46', 'completed', 82, 2, '2025-09-17 19:27:01'),
	(72, 6, 'ranked_5v5', 1215, '2025-09-17 19:56:17', 'completed', 83, 2, '2025-09-17 20:08:01'),
	(73, 7, 'ranked_5v5', 1227, '2025-09-17 19:56:18', 'completed', 83, 1, '2025-09-17 20:08:01'),
	(74, 7, 'ranked_5v5', 1239, '2025-09-18 11:52:32', 'completed', 84, 1, '2025-09-18 12:05:01'),
	(75, 6, 'ranked_5v5', 1199, '2025-09-18 11:52:49', 'completed', 84, 2, '2025-09-18 12:05:01'),
	(76, 7, 'ranked_5v5', 1238, '2025-09-18 12:11:20', 'completed', 85, 1, '2025-09-18 12:23:01'),
	(77, 6, 'ranked_5v5', 1200, '2025-09-18 12:11:30', 'completed', 85, 2, '2025-09-18 12:23:01'),
	(78, 7, 'ranked_5v5', 1237, '2025-09-18 12:44:07', 'completed', 86, 1, '2025-09-18 12:56:01'),
	(79, 6, 'ranked_5v5', 1201, '2025-09-18 12:44:41', 'completed', 86, 2, '2025-09-18 12:56:01'),
	(80, 9, 'ranked_5v5', 1200, '2025-09-18 13:01:34', 'completed', 87, 2, '2025-09-18 13:49:01'),
	(81, 7, 'ranked_5v5', 1236, '2025-09-18 13:10:27', 'completed', 87, 1, '2025-09-18 13:49:01'),
	(82, 9, 'ranked_5v5', 1217, '2025-09-18 13:53:27', 'cancelled', NULL, NULL, NULL),
	(83, 7, 'ranked_5v5', 1223, '2025-09-18 14:28:56', 'completed', 88, 1, '2025-09-18 14:41:01'),
	(84, 6, 'ranked_5v5', 1202, '2025-09-18 14:29:04', 'completed', 88, 2, '2025-09-18 14:41:01'),
	(85, 7, 'ranked_5v5', 1223, '2025-09-18 16:42:58', 'completed', 89, 2, '2025-09-18 17:03:01'),
	(86, 6, 'ranked_5v5', 1203, '2025-09-18 16:43:12', 'completed', 89, 1, '2025-09-18 17:03:01'),
	(87, 8, 'ranked_5v5', 1258, '2025-09-18 16:45:00', 'completed', 89, 1, '2025-09-18 17:03:01'),
	(88, 10, 'ranked_5v5', 1200, '2025-09-18 16:46:29', 'completed', 89, 0, '2025-09-18 17:03:01'),
	(89, 7, 'ranked_5v5', 1223, '2025-09-18 17:19:44', 'completed', 90, 2, '2025-09-18 18:01:41'),
	(90, 6, 'ranked_5v5', 1204, '2025-09-18 17:19:54', 'completed', 90, 1, '2025-09-18 18:01:41'),
	(91, 10, 'ranked_5v5', 1200, '2025-09-18 17:20:02', 'completed', 90, 2, '2025-09-18 18:01:41'),
	(92, 8, 'ranked_5v5', 1257, '2025-09-18 17:20:38', 'completed', 90, 1, '2025-09-18 18:01:41'),
	(93, 7, 'ranked_2v2_enabled', 1200, '2025-09-18 19:14:24', 'cancelled', NULL, NULL, NULL),
	(94, 7, 'ranked_2v2', 1200, '2025-09-18 19:38:42', 'cancelled', NULL, NULL, NULL),
	(95, 7, 'ranked_2v2', 1200, '2025-09-18 20:28:45', 'matched', 91, 1, '2025-09-18 20:33:11'),
	(96, 6, 'ranked_2v2', 1200, '2025-09-18 20:28:54', 'matched', 91, 2, '2025-09-18 20:33:11');

-- Dumping structure for table gcdm_global.match_archives
CREATE TABLE IF NOT EXISTS `match_archives` (
  `archive_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `match_id` bigint(20) NOT NULL,
  `archive_location` varchar(255) NOT NULL,
  `archive_type` enum('database','json','compressed') DEFAULT 'database',
  `archive_size_mb` decimal(10,2) DEFAULT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`archive_id`),
  KEY `idx_archive_match` (`match_id`),
  KEY `idx_archive_created` (`created_at`),
  CONSTRAINT `match_archives_ibfk_1` FOREIGN KEY (`match_id`) REFERENCES `matches` (`match_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

-- Dumping data for table gcdm_global.match_archives: ~0 rows (approximately)

-- Dumping structure for table gcdm_global.match_lobby_config
CREATE TABLE IF NOT EXISTS `match_lobby_config` (
  `setting_key` varchar(64) NOT NULL,
  `setting_value` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  PRIMARY KEY (`setting_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

-- Dumping data for table gcdm_global.match_lobby_config: ~5 rows (approximately)
INSERT INTO `match_lobby_config` (`setting_key`, `setting_value`, `description`) VALUES
	('allow_late_join', 'false', 'Allow players to join after match has started'),
	('auto_start_when_ready', 'true', 'Automatically start match when all players are ready'),
	('match_start_countdown', '30', 'Countdown seconds after all players ready'),
	('min_ready_percentage', '100', 'Percentage of players that must be ready to start (100 = all)'),
	('ready_timeout_seconds', '90', 'Time players have to ready up before match is cancelled');

-- Dumping structure for table gcdm_global.match_players
CREATE TABLE IF NOT EXISTS `match_players` (
  `match_id` bigint(20) NOT NULL,
  `user_id` int(11) NOT NULL COMMENT 'User ID within the match (1-99 for Team A, 100-199 for Team B)',
  `global_account_id` int(11) NOT NULL,
  `team` char(1) NOT NULL COMMENT 'A or B',
  `joined_at` datetime DEFAULT current_timestamp(),
  `ready_status` enum('not_ready','ready','timeout') DEFAULT 'not_ready',
  `ready_at` datetime DEFAULT NULL,
  PRIMARY KEY (`match_id`,`global_account_id`),
  KEY `idx_global_account` (`global_account_id`),
  KEY `idx_team` (`team`),
  KEY `idx_ready` (`ready_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

-- Dumping data for table gcdm_global.match_players: ~39 rows (approximately)
INSERT INTO `match_players` (`match_id`, `user_id`, `global_account_id`, `team`, `joined_at`, `ready_status`, `ready_at`) VALUES
	(73, 1133, 6, 'B', '2025-09-17 13:37:01', 'ready', '2025-09-17 13:37:11'),
	(73, 1132, 7, 'A', '2025-09-17 13:37:01', 'ready', '2025-09-17 13:37:13'),
	(74, 1135, 6, 'B', '2025-09-17 13:52:01', 'ready', '2025-09-17 13:52:20'),
	(74, 1134, 7, 'A', '2025-09-17 13:52:01', 'ready', '2025-09-17 13:52:22'),
	(75, 1137, 6, 'B', '2025-09-17 14:21:01', 'ready', '2025-09-17 14:21:12'),
	(75, 1136, 7, 'A', '2025-09-17 14:21:01', 'ready', '2025-09-17 14:21:13'),
	(76, 1144, 6, 'B', '2025-09-17 14:43:02', 'ready', '2025-09-17 14:43:07'),
	(76, 1143, 7, 'A', '2025-09-17 14:43:02', 'ready', '2025-09-17 14:43:09'),
	(77, 1145, 6, 'A', '2025-09-17 15:55:01', 'ready', '2025-09-17 15:55:08'),
	(77, 1146, 7, 'B', '2025-09-17 15:55:01', 'ready', '2025-09-17 15:55:10'),
	(78, 1148, 6, 'B', '2025-09-17 16:33:01', 'ready', '2025-09-17 16:33:23'),
	(78, 1147, 7, 'A', '2025-09-17 16:33:01', 'ready', '2025-09-17 16:33:19'),
	(79, 1155, 6, 'B', '2025-09-17 18:21:01', 'ready', '2025-09-17 18:21:08'),
	(79, 1154, 7, 'A', '2025-09-17 18:21:01', 'ready', '2025-09-17 18:21:06'),
	(80, 1157, 6, 'B', '2025-09-17 18:38:01', 'ready', '2025-09-17 18:38:15'),
	(80, 1156, 7, 'A', '2025-09-17 18:38:01', 'ready', '2025-09-17 18:38:13'),
	(81, 1159, 6, 'B', '2025-09-17 18:56:01', 'ready', '2025-09-17 18:56:09'),
	(81, 1158, 7, 'A', '2025-09-17 18:56:01', 'ready', '2025-09-17 18:56:10'),
	(82, 1166, 6, 'B', '2025-09-17 19:12:01', 'ready', '2025-09-17 19:12:05'),
	(82, 1165, 7, 'A', '2025-09-17 19:12:01', 'ready', '2025-09-17 19:12:08'),
	(83, 1173, 6, 'B', '2025-09-17 19:57:01', 'ready', '2025-09-17 19:57:17'),
	(83, 1172, 7, 'A', '2025-09-17 19:57:01', 'ready', '2025-09-17 19:57:15'),
	(84, 1175, 6, 'B', '2025-09-18 11:53:01', 'ready', '2025-09-18 11:53:57'),
	(84, 1174, 7, 'A', '2025-09-18 11:53:01', 'ready', '2025-09-18 11:53:51'),
	(85, 1177, 6, 'B', '2025-09-18 12:12:01', 'ready', '2025-09-18 12:12:14'),
	(85, 1176, 7, 'A', '2025-09-18 12:12:01', 'ready', '2025-09-18 12:12:12'),
	(86, 1179, 6, 'B', '2025-09-18 12:45:01', 'ready', '2025-09-18 12:45:10'),
	(86, 1178, 7, 'A', '2025-09-18 12:45:01', 'ready', '2025-09-18 12:45:08'),
	(87, 1180, 7, 'A', '2025-09-18 13:11:01', 'ready', '2025-09-18 13:11:25'),
	(87, 1181, 9, 'B', '2025-09-18 13:11:01', 'ready', '2025-09-18 13:11:22'),
	(88, 1183, 6, 'B', '2025-09-18 14:30:01', 'ready', '2025-09-18 14:30:24'),
	(88, 1182, 7, 'A', '2025-09-18 14:30:01', 'ready', '2025-09-18 14:30:10'),
	(89, 1190, 6, 'A', '2025-09-18 16:51:51', 'ready', '2025-09-18 16:52:29'),
	(89, 1191, 7, 'B', '2025-09-18 16:51:51', 'ready', '2025-09-18 16:52:23'),
	(89, 1189, 8, 'A', '2025-09-18 16:51:51', 'ready', '2025-09-18 16:52:19'),
	(90, 1193, 6, 'A', '2025-09-18 17:20:41', 'ready', '2025-09-18 17:20:47'),
	(90, 1194, 7, 'B', '2025-09-18 17:20:41', 'ready', '2025-09-18 17:20:51'),
	(90, 1192, 8, 'A', '2025-09-18 17:20:41', 'ready', '2025-09-18 17:21:03'),
	(90, 1195, 10, 'B', '2025-09-18 17:20:41', 'ready', '2025-09-18 17:20:59'),
	(91, 1202, 6, 'B', '2025-09-18 20:33:11', 'ready', '2025-09-18 20:33:19'),
	(91, 1201, 7, 'A', '2025-09-18 20:33:11', 'ready', '2025-09-18 20:33:21');

-- Dumping structure for table gcdm_global.match_results
CREATE TABLE IF NOT EXISTS `match_results` (
  `match_id` bigint(20) NOT NULL,
  `global_account_id` int(11) NOT NULL,
  `game_mode` varchar(32) NOT NULL DEFAULT 'ranked_5v5',
  `team_fed` int(11) NOT NULL,
  `mmr_before` int(11) NOT NULL,
  `mmr_after` int(11) NOT NULL,
  `mmr_change` int(11) NOT NULL,
  `result` enum('win','loss','draw') NOT NULL,
  `war_points_earned` int(11) DEFAULT 0,
  `colonies_captured` int(11) DEFAULT 0,
  `colonies_lost` int(11) DEFAULT 0,
  `final_power` int(11) DEFAULT 0,
  `final_colonies` int(11) DEFAULT 0,
  `match_length_minutes` int(11) DEFAULT NULL,
  `performance_rating` int(11) DEFAULT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  PRIMARY KEY (`match_id`,`global_account_id`),
  KEY `idx_results_player` (`global_account_id`,`created_at`),
  KEY `idx_results_match` (`match_id`),
  CONSTRAINT `match_results_ibfk_1` FOREIGN KEY (`match_id`) REFERENCES `matches` (`match_id`) ON DELETE CASCADE,
  CONSTRAINT `match_results_ibfk_2` FOREIGN KEY (`global_account_id`) REFERENCES `global_account` (`account_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

-- Dumping data for table gcdm_global.match_results: ~53 rows (approximately)
INSERT INTO `match_results` (`match_id`, `global_account_id`, `game_mode`, `team_fed`, `mmr_before`, `mmr_after`, `mmr_change`, `result`, `war_points_earned`, `colonies_captured`, `colonies_lost`, `final_power`, `final_colonies`, `match_length_minutes`, `performance_rating`, `created_at`) VALUES
	(13, 6, 'ranked_5v5', 2, 1200, 1184, -16, 'loss', 0, 0, 0, 0, 0, 60, NULL, '2025-09-13 13:17:01'),
	(13, 7, 'ranked_5v5', 1, 1200, 1216, 16, 'win', 0, 0, 0, 0, 0, 60, NULL, '2025-09-13 13:17:01'),
	(14, 7, 'ranked_5v5', 1, 1216, 1200, -16, 'loss', 0, 0, 0, 0, 0, 78, NULL, '2025-09-15 17:00:02'),
	(14, 8, 'ranked_5v5', 2, 1200, 1216, 16, 'win', 0, 0, 0, 0, 0, 78, NULL, '2025-09-15 17:00:02'),
	(15, 7, 'ranked_5v5', 2, 1200, 1184, -16, 'loss', 0, 0, 0, 0, 0, 5, NULL, '2025-09-15 17:13:01'),
	(15, 8, 'ranked_5v5', 1, 1216, 1232, 16, 'win', 0, 0, 0, 0, 0, 5, NULL, '2025-09-15 17:13:01'),
	(16, 7, 'ranked_5v5', 2, 1184, 1169, -15, 'loss', 0, 0, 0, 0, 0, 5, NULL, '2025-09-15 17:31:01'),
	(16, 8, 'ranked_5v5', 1, 1232, 1247, 15, 'win', 0, 0, 0, 0, 0, 5, NULL, '2025-09-15 17:31:01'),
	(17, 7, 'ranked_5v5', 2, 1169, 1187, 18, 'win', 0, 0, 0, 0, 0, 10, NULL, '2025-09-15 17:46:01'),
	(17, 8, 'ranked_5v5', 1, 1247, 1229, -18, 'loss', 0, 0, 0, 0, 0, 10, NULL, '2025-09-15 17:46:01'),
	(19, 7, 'ranked_5v5', 2, 1187, 1172, -15, 'loss', 0, 0, 0, 0, 0, 10, NULL, '2025-09-15 18:06:01'),
	(19, 8, 'ranked_5v5', 1, 1229, 1244, 15, 'win', 0, 0, 0, 0, 0, 10, NULL, '2025-09-15 18:06:01'),
	(20, 7, 'ranked_5v5', 2, 1172, 1158, -14, 'loss', 0, 0, 0, 0, 0, 10, NULL, '2025-09-15 18:23:01'),
	(20, 8, 'ranked_5v5', 1, 1244, 1258, 14, 'win', 0, 0, 0, 0, 0, 10, NULL, '2025-09-15 18:23:01'),
	(21, 6, 'ranked_5v5', 1, 1184, 1199, 15, 'win', 0, 0, 0, 0, 0, 10, NULL, '2025-09-15 19:59:01'),
	(21, 7, 'ranked_5v5', 2, 1158, 1143, -15, 'loss', 0, 0, 0, 0, 0, 10, NULL, '2025-09-15 19:59:01'),
	(22, 6, 'ranked_5v5', 1, 1199, 1214, 15, 'win', 0, 0, 0, 0, 0, 10, NULL, '2025-09-15 20:12:01'),
	(22, 7, 'ranked_5v5', 2, 1143, 1128, -15, 'loss', 0, 0, 0, 0, 0, 10, NULL, '2025-09-15 20:12:01'),
	(73, 6, 'ranked_5v5', 2, 1214, 1198, -16, 'loss', 0, 0, 0, 0, 0, 10, NULL, '2025-09-17 13:48:01'),
	(73, 7, 'ranked_5v5', 1, 1228, 1244, 16, 'win', 0, 0, 0, 0, 0, 10, NULL, '2025-09-17 13:48:01'),
	(74, 6, 'ranked_5v5', 2, 1198, 1215, 17, 'win', 0, 0, 0, 0, 0, 10, NULL, '2025-09-17 14:05:01'),
	(74, 7, 'ranked_5v5', 1, 1244, 1227, -17, 'loss', 0, 0, 0, 0, 0, 10, NULL, '2025-09-17 14:05:01'),
	(75, 6, 'ranked_5v5', 2, 1215, 1215, 0, 'draw', 0, 0, 0, 0, 0, 5, NULL, '2025-09-17 14:42:01'),
	(75, 7, 'ranked_5v5', 1, 1227, 1227, 0, 'draw', 0, 0, 0, 0, 0, 5, NULL, '2025-09-17 14:42:01'),
	(76, 6, 'ranked_5v5', 2, 1215, 1231, 16, 'win', 0, 0, 0, 0, 0, 10, NULL, '2025-09-17 14:56:01'),
	(76, 7, 'ranked_5v5', 1, 1227, 1211, -16, 'loss', 0, 0, 0, 0, 0, 10, NULL, '2025-09-17 14:56:01'),
	(77, 6, 'ranked_5v5', 141, 1231, 1215, -16, 'loss', 15, 0, 2, 13580, 0, NULL, 1006, '2025-09-17 16:04:01'),
	(77, 7, 'ranked_5v5', 142, 1211, 1227, 16, 'win', 25, 2, 0, 20514, 0, NULL, 1415, '2025-09-17 16:04:01'),
	(78, 6, 'ranked_5v5', 144, 1215, 1215, 0, 'draw', 0, 0, 0, 1500, 1, 22, 1015, '2025-09-17 17:58:01'),
	(78, 7, 'ranked_5v5', 143, 1227, 1227, 0, 'draw', 0, 0, 0, 1500, 1, 22, 1015, '2025-09-17 17:58:01'),
	(79, 6, 'ranked_5v5', 146, 1215, 1215, 0, 'draw', 0, 0, 0, 1500, 1, 10, 1015, '2025-09-17 18:34:01'),
	(79, 7, 'ranked_5v5', 145, 1227, 1227, 0, 'draw', 0, 0, 0, 1500, 1, 10, 1015, '2025-09-17 18:34:01'),
	(80, 6, 'ranked_5v5', 148, 1215, 1215, 0, 'draw', 0, 0, 0, 1500, 1, 10, 1015, '2025-09-17 18:51:01'),
	(80, 7, 'ranked_5v5', 147, 1227, 1227, 0, 'draw', 0, 0, 0, 1500, 1, 10, 1015, '2025-09-17 18:51:01'),
	(81, 6, 'ranked_5v5', 150, 1215, 1215, 0, 'draw', 0, 0, 0, 1500, 1, 10, 1015, '2025-09-17 19:09:02'),
	(81, 7, 'ranked_5v5', 149, 1227, 1227, 0, 'draw', 0, 0, 0, 1500, 1, 10, 1015, '2025-09-17 19:09:02'),
	(82, 6, 'ranked_5v5', 152, 1215, 1215, 0, 'draw', 0, 0, 0, 1500, 1, 10, 1015, '2025-09-17 19:27:01'),
	(82, 7, 'ranked_5v5', 151, 1227, 1227, 0, 'draw', 0, 0, 0, 1500, 1, 10, 1015, '2025-09-17 19:27:01'),
	(83, 6, 'ranked_5v5', 154, 1215, 1199, -16, 'loss', 0, 0, 3, 1201, 1, 10, 852, '2025-09-17 20:08:01'),
	(83, 7, 'ranked_5v5', 153, 1227, 1239, 12, 'win', 50, 3, 0, 24065, 1, 10, 1461, '2025-09-17 20:08:01'),
	(84, 6, 'ranked_5v5', 156, 1199, 1200, 1, 'draw', 0, 0, 0, 1500, 1, 10, 1025, '2025-09-18 12:05:01'),
	(84, 7, 'ranked_5v5', 155, 1239, 1238, -1, 'draw', 0, 0, 0, 1500, 1, 10, 1005, '2025-09-18 12:05:01'),
	(85, 6, 'ranked_5v5', 158, 1200, 1201, 1, 'draw', 0, 0, 0, 1500, 1, 10, 1025, '2025-09-18 12:23:01'),
	(85, 7, 'ranked_5v5', 157, 1238, 1237, -1, 'draw', 0, 0, 0, 1500, 1, 10, 1005, '2025-09-18 12:23:01'),
	(86, 6, 'ranked_5v5', 160, 1201, 1202, 1, 'draw', 0, 0, 0, 1500, 1, 10, 1025, '2025-09-18 12:56:01'),
	(86, 7, 'ranked_5v5', 159, 1237, 1236, -1, 'draw', 0, 0, 0, 1500, 1, 10, 1005, '2025-09-18 12:56:01'),
	(87, 7, 'ranked_5v5', 161, 1236, 1223, -13, 'loss', 0, 0, 3, 1500, 1, 10, 885, '2025-09-18 13:49:01'),
	(87, 9, 'ranked_5v5', 162, 1200, 1217, 17, 'win', 50, 3, 0, 25158, 5, 10, 1522, '2025-09-18 13:49:01'),
	(88, 6, 'ranked_5v5', 164, 1202, 1203, 1, 'draw', 0, 0, 0, 1500, 1, 10, 1025, '2025-09-18 14:41:01'),
	(88, 7, 'ranked_5v5', 163, 1223, 1223, 0, 'draw', 0, 0, 0, 1500, 1, 10, 1015, '2025-09-18 14:41:01'),
	(89, 6, 'ranked_5v5', 165, 1203, 1204, 1, 'draw', 0, 0, 0, 1500, 1, 10, 1025, '2025-09-18 17:03:01'),
	(89, 7, 'ranked_5v5', 166, 1223, 1223, 0, 'draw', 0, 0, 0, 1500, 1, 10, 1015, '2025-09-18 17:03:01'),
	(89, 8, 'ranked_5v5', 165, 1258, 1257, -1, 'draw', 0, 0, 0, 1500, 1, 10, 1005, '2025-09-18 17:03:01'),
	(90, 6, 'ranked_5v5', 167, 1204, 1189, -15, 'loss', 0, 0, 2, 40571, 2, 10, 1256, '2025-09-18 18:01:41'),
	(90, 7, 'ranked_5v5', 168, 1223, 1235, 12, 'win', 25, 2, 0, 104849, 10, 10, 2218, '2025-09-18 18:01:41'),
	(90, 8, 'ranked_5v5', 167, 1257, 1239, -18, 'loss', 0, 0, 0, 1500, 1, 10, 835, '2025-09-18 18:01:41'),
	(90, 10, 'ranked_5v5', 168, 1200, 1217, 17, 'win', 0, 0, 0, 1500, 1, 10, 1185, '2025-09-18 18:01:41');

-- Dumping structure for table gcdm_global.player_mmr
CREATE TABLE IF NOT EXISTS `player_mmr` (
  `global_account_id` int(11) NOT NULL,
  `game_mode` varchar(32) NOT NULL DEFAULT 'ranked_5v5',
  `mmr` int(11) DEFAULT 1200,
  `games_played` int(11) DEFAULT 0,
  `wins` int(11) DEFAULT 0,
  `losses` int(11) DEFAULT 0,
  `draws` int(11) DEFAULT 0,
  `win_streak` int(11) DEFAULT 0,
  `loss_streak` int(11) DEFAULT 0,
  `highest_mmr` int(11) DEFAULT 1200,
  `lowest_mmr` int(11) DEFAULT 1200,
  `last_match_id` bigint(20) DEFAULT NULL,
  `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`global_account_id`,`game_mode`),
  KEY `idx_mmr_ranking` (`game_mode`,`mmr`),
  KEY `idx_updated` (`updated_at`),
  CONSTRAINT `player_mmr_ibfk_1` FOREIGN KEY (`global_account_id`) REFERENCES `global_account` (`account_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

-- Dumping data for table gcdm_global.player_mmr: ~7 rows (approximately)
INSERT INTO `player_mmr` (`global_account_id`, `game_mode`, `mmr`, `games_played`, `wins`, `losses`, `draws`, `win_streak`, `loss_streak`, `highest_mmr`, `lowest_mmr`, `last_match_id`, `updated_at`) VALUES
	(5, 'ranked_5v5', 1216, 1, 1, 0, 0, 0, 0, 1216, 1200, 5, '2025-09-11 17:18:50'),
	(6, 'ranked_2v2', 1200, 0, 0, 0, 0, 0, 0, 1200, 1200, NULL, '2025-09-18 20:28:54'),
	(6, 'ranked_5v5', 1189, 20, 4, 5, 11, 0, 0, 1231, 1184, 90, '2025-09-18 18:01:41'),
	(7, 'ranked_2v2', 1200, 0, 0, 0, 0, 0, 0, 1200, 1200, NULL, '2025-09-18 19:38:42'),
	(7, 'ranked_2v2_enabled', 1200, 0, 0, 0, 0, 0, 0, 1200, 1200, NULL, '2025-09-18 19:14:24'),
	(7, 'ranked_5v5', 1235, 29, 6, 10, 13, 0, 0, 1244, 1128, 90, '2025-09-18 18:01:41'),
	(8, 'ranked_5v5', 1239, 8, 5, 2, 1, 0, 0, 1258, 1200, 90, '2025-09-18 18:01:41'),
	(9, 'ranked_5v5', 1217, 1, 1, 0, 0, 0, 0, 1217, 1200, 87, '2025-09-18 13:49:01'),
	(10, 'ranked_5v5', 1217, 1, 1, 0, 0, 0, 0, 1217, 1200, 90, '2025-09-18 18:01:41'),
	(11, 'ranked_5v5', 1200, 0, 0, 0, 0, 0, 0, 1200, 1200, NULL, '2025-09-18 17:25:16');

-- Dumping structure for table gcdm_global.player_stats
CREATE TABLE IF NOT EXISTS `player_stats` (
  `global_account_id` int(11) NOT NULL,
  `total_matches` int(11) DEFAULT 0,
  `total_wins` int(11) DEFAULT 0,
  `total_losses` int(11) DEFAULT 0,
  `total_draws` int(11) DEFAULT 0,
  `total_war_points` int(11) DEFAULT 0,
  `total_colonies_captured` int(11) DEFAULT 0,
  `total_ships_destroyed` int(11) DEFAULT 0,
  `favorite_race_id` int(11) DEFAULT NULL,
  `last_played` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`global_account_id`),
  KEY `idx_stats_wins` (`total_wins`),
  KEY `idx_stats_points` (`total_war_points`),
  CONSTRAINT `player_stats_ibfk_1` FOREIGN KEY (`global_account_id`) REFERENCES `global_account` (`account_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

-- Dumping data for table gcdm_global.player_stats: ~7 rows (approximately)
INSERT INTO `player_stats` (`global_account_id`, `total_matches`, `total_wins`, `total_losses`, `total_draws`, `total_war_points`, `total_colonies_captured`, `total_ships_destroyed`, `favorite_race_id`, `last_played`, `updated_at`) VALUES
	(5, 1, 1, 0, 0, 0, 0, 0, NULL, '2025-09-11 17:18:50', '2025-09-11 17:18:50'),
	(6, 20, 4, 5, 11, 15, 0, 0, NULL, '2025-09-18 18:01:41', '2025-09-18 18:01:41'),
	(7, 29, 6, 10, 13, 100, 0, 0, NULL, '2025-09-18 18:01:41', '2025-09-18 18:01:41'),
	(8, 8, 5, 2, 1, 0, 0, 0, NULL, '2025-09-18 18:01:41', '2025-09-18 18:01:41'),
	(9, 1, 1, 0, 0, 50, 0, 0, NULL, '2025-09-18 13:49:01', '2025-09-18 13:49:01'),
	(10, 1, 1, 0, 0, 0, 0, 0, NULL, '2025-09-18 18:01:41', '2025-09-18 18:01:41'),
	(11, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, '2025-09-18 17:25:16');

-- Dumping structure for table gcdm_global.season_rankings
CREATE TABLE IF NOT EXISTS `season_rankings` (
  `season_id` int(11) NOT NULL,
  `global_account_id` int(11) NOT NULL,
  `final_mmr` int(11) NOT NULL,
  `final_rank` int(11) NOT NULL,
  `matches_played` int(11) DEFAULT 0,
  `wins` int(11) DEFAULT 0,
  `losses` int(11) DEFAULT 0,
  `reward_tier` varchar(32) DEFAULT NULL,
  PRIMARY KEY (`season_id`,`global_account_id`),
  KEY `global_account_id` (`global_account_id`),
  KEY `idx_ranking_season` (`season_id`,`final_rank`),
  CONSTRAINT `season_rankings_ibfk_1` FOREIGN KEY (`season_id`) REFERENCES `competitive_seasons` (`season_id`) ON DELETE CASCADE,
  CONSTRAINT `season_rankings_ibfk_2` FOREIGN KEY (`global_account_id`) REFERENCES `global_account` (`account_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

-- Dumping data for table gcdm_global.season_rankings: ~0 rows (approximately)

-- Dumping structure for table gcdm_global.server_settings
CREATE TABLE IF NOT EXISTS `server_settings` (
  `setting_id` int(11) NOT NULL AUTO_INCREMENT,
  `setting_key` varchar(64) NOT NULL,
  `setting_value` text NOT NULL,
  `description` text DEFAULT NULL,
  `created_at` datetime DEFAULT current_timestamp(),
  `updated_at` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`setting_id`),
  UNIQUE KEY `setting_key` (`setting_key`),
  KEY `idx_setting_key` (`setting_key`)
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;

-- Dumping data for table gcdm_global.server_settings: ~28 rows (approximately)
INSERT INTO `server_settings` (`setting_id`, `setting_key`, `setting_value`, `description`, `created_at`, `updated_at`) VALUES
	(1, 'match_duration_minutes', '30', 'Duration of matches in minutes', '2025-09-10 10:07:31', '2025-09-18 19:29:33'),
	(2, 'match_team_size', '2', 'Number of players per team', '2025-09-10 10:07:31', '2025-09-18 16:41:44'),
	(3, 'match_turnmin_seconds', '0.50', 'Minimum seconds per turn', '2025-09-10 10:07:31', '2025-09-18 19:29:26'),
	(4, 'match_turnmax', '1000', 'Maximum number of turns per match', '2025-09-10 10:07:31', '2025-09-10 10:10:15'),
	(5, 'max_concurrent_matches', '20', 'Maximum number of concurrent matches allowed', '2025-09-10 10:07:31', '2025-09-10 10:07:31'),
	(6, 'matchmaking_enabled', '1', 'Whether matchmaking system is enabled (1=yes, 0=no)', '2025-09-10 10:07:31', '2025-09-10 10:07:31'),
	(7, 'queue_timeout_minutes', '25', 'Minutes before queue entries expire', '2025-09-10 10:07:31', '2025-09-18 16:47:58'),
	(8, 'queue_check_interval', '15', 'Seconds between queue processing runs', '2025-09-10 10:07:31', '2025-09-10 10:10:26'),
	(9, 'initial_mmr', '1200', 'Starting MMR for new players', '2025-09-10 10:07:31', '2025-09-10 10:07:31'),
	(10, 'mmr_min_gain', '10', 'Minimum MMR gained from a win', '2025-09-10 10:07:31', '2025-09-10 10:07:31'),
	(11, 'mmr_max_gain', '50', 'Maximum MMR gained from a win', '2025-09-10 10:07:31', '2025-09-10 10:07:31'),
	(12, 'mmr_min_loss', '10', 'Minimum MMR lost from a loss', '2025-09-10 10:07:31', '2025-09-10 10:07:31'),
	(13, 'mmr_max_loss', '50', 'Maximum MMR lost from a loss', '2025-09-10 10:07:31', '2025-09-10 10:07:31'),
	(55, 'war_points_attack_1col', '10', 'Points awarded for capturing 1 colony in war battles', '2025-09-17 14:19:26', '2025-09-17 14:19:26'),
	(56, 'war_points_attack_2col', '25', 'Points awarded for capturing 2 colonies in war battles', '2025-09-17 14:19:26', '2025-09-17 14:19:26'),
	(57, 'war_points_attack_3col', '50', 'Points awarded for capturing 3 colonies in war battles', '2025-09-17 14:19:26', '2025-09-17 14:19:26'),
	(58, 'war_points_defense_win', '15', 'Points awarded for successfully defending against attack', '2025-09-17 14:19:26', '2025-09-17 14:19:26'),
	(59, 'war_points_attack_loss', '0', 'Points deducted for losing an attack (can be negative)', '2025-09-17 14:19:26', '2025-09-17 14:19:26'),
	(74, 'match_duration_minutes_ranked_2v2', '25', 'Duration of 2v2 matches in minutes', '2025-09-18 18:56:23', '2025-09-18 19:29:43'),
	(75, 'match_team_size_ranked_2v2', '1', 'Number of players per team in 2v2 mode', '2025-09-18 18:56:23', '2025-09-18 19:27:49'),
	(76, 'match_turnmin_seconds_ranked_2v2', '0.50', 'Minimum seconds per turn in 2v2 matches', '2025-09-18 18:56:23', '2025-09-18 19:29:22'),
	(77, 'match_turnmax_ranked_2v2', '1000', 'Maximum number of turns per 2v2 match', '2025-09-18 18:56:23', '2025-09-18 19:29:18'),
	(78, 'queue_timeout_minutes_ranked_2v2', '20', 'Minutes before 2v2 queue entries expire', '2025-09-18 18:56:23', '2025-09-18 18:56:23'),
	(79, 'mmr_k_factor_ranked_2v2', '32', 'MMR adjustment factor for 2v2 matches (higher = more volatile)', '2025-09-18 18:56:23', '2025-09-18 18:56:23'),
	(80, 'game_mode_ranked_5v5_enabled', '1', 'Whether 5v5 ranked mode is available (1=yes, 0=no)', '2025-09-18 18:56:23', '2025-09-18 18:56:23'),
	(81, 'game_mode_ranked_2v2_enabled', '1', 'Whether 2v2 ranked mode is available (1=yes, 0=no)', '2025-09-18 18:56:23', '2025-09-18 18:56:23'),
	(82, 'game_mode_ranked_5v5_display_name', '2v2 Ranked', 'Display name for 2v2 mode', '2025-09-18 18:56:23', '2025-09-18 19:28:49'),
	(83, 'game_mode_ranked_2v2_display_name', '1v1 Ranked', 'Display name for 1v1 mode', '2025-09-18 18:56:23', '2025-09-18 19:28:45');

