/* RAIET v1.45.1 — anti-abuse foundation.
   Run once after 032_system_health.sql. */

CREATE TABLE IF NOT EXISTS security_maintenance_locks (
    task_key VARCHAR(64) NOT NULL,
    next_run_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,
    PRIMARY KEY (task_key),
    KEY idx_security_maintenance_next (next_run_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/* Fast duplicate-message lookup without retaining any extra chat history. */
ALTER TABLE lobby_chat_messages
    ADD KEY idx_lobby_chat_sender (lobby_id, user_id, id);
