/* RAIET v1.32 — Quick Match foundation. Run once after 014_user_blocks.sql. */
ALTER TABLE lobbies
    ADD COLUMN lobby_type ENUM('manual','quick') NOT NULL DEFAULT 'manual' AFTER server_port,
    ADD KEY idx_lobbies_quick_match (status, lobby_type, game_key, region, ready_check_started_at, created_at);

/* One tiny row per game/region serializes automatic queue creation so two
   simultaneous users cannot create duplicate Quick Match lobbies. */
CREATE TABLE IF NOT EXISTS quick_match_locks (
    game_key VARCHAR(32) NOT NULL,
    region VARCHAR(32) NOT NULL,
    updated_at DATETIME NOT NULL,
    PRIMARY KEY (game_key, region)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
