-- Shared login rate limiter for both API replicas. -- One bucket per normalized username. -- Only SHA-256 of the bucket identity is stored. CREATE TABLE IF NOT EXISTS login_attempt_buckets ( bucket_key TEXT PRIMARY KEY, window_started_at TIMESTAMPTZ NOT NULL, attempts INTEGER NOT NULL DEFAULT 0 CHECK (attempts >= 0) ); CREATE INDEX IF NOT EXISTS idx_login_attempt_buckets_window ON login_attempt_buckets (window_started_at);