CREATE TABLE login_budget ( scope text NOT NULL, window_start bigint NOT NULL, attempts integer NOT NULL CHECK (attempts > 0), PRIMARY KEY (scope, window_start) ); CREATE INDEX login_budget_window ON login_budget(window_start);