ALTER TABLE idempotency_keys
  ALTER COLUMN response_body DROP NOT NULL;

ALTER TABLE idempotency_keys
  ADD COLUMN IF NOT EXISTS status text NOT NULL DEFAULT 'completed'
  CHECK (status IN ('processing', 'completed'));

ALTER TABLE idempotency_keys
  ADD COLUMN IF NOT EXISTS locked_until timestamptz;

CREATE INDEX IF NOT EXISTS idempotency_keys_status_idx ON idempotency_keys(status);
CREATE INDEX IF NOT EXISTS idempotency_keys_locked_until_idx ON idempotency_keys(locked_until);
