-- migrate:up
-- First, delete any existing login requests (they're temporary auth state anyway)
DELETE FROM login_requests;

-- Make token column required and add unique constraint
ALTER TABLE login_requests
  ALTER COLUMN token SET NOT NULL,
  ADD CONSTRAINT login_requests_token_unique UNIQUE (token);

-- Create index for token lookups
CREATE INDEX idx_login_requests_token ON login_requests(token);

-- migrate:down
DROP INDEX IF EXISTS idx_login_requests_token;
ALTER TABLE login_requests
  DROP CONSTRAINT IF EXISTS login_requests_token_unique,
  ALTER COLUMN token DROP NOT NULL;
