CREATE TABLE IF NOT EXISTS security_rate_limits (
    key_hash CHAR(64) NOT NULL,
    action VARCHAR(64) NOT NULL,
    window_started_at DATETIME NOT NULL,
    attempts INT UNSIGNED NOT NULL DEFAULT 0,
    expires_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,
    PRIMARY KEY (key_hash),
    KEY idx_security_rate_limits_expires (expires_at),
    KEY idx_security_rate_limits_action (action)
) ENGINE=InnoDB
  DEFAULT CHARSET=utf8mb4
  COLLATE=utf8mb4_unicode_ci;
