CREATE TABLE IF NOT EXISTS rate_limits (
    id           BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    identifier   VARCHAR(255)    NOT NULL,
    action       VARCHAR(50)     NOT NULL,
    hits         SMALLINT UNSIGNED DEFAULT 1,
    window_start DATETIME        NOT NULL DEFAULT CURRENT_TIMESTAMP,
    UNIQUE KEY uq_ident_action (identifier, action),
    INDEX idx_window (window_start)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
