ALTER TYPE "PaymentProvider" ADD VALUE IF NOT EXISTS 'MANUAL';

ALTER TABLE "rental_payments"
  ADD COLUMN "reference" TEXT,
  ADD COLUMN "note" TEXT,
  ADD COLUMN "receivedAt" TIMESTAMP(3),
  ADD COLUMN "recordedByEmployeeId" TEXT,
  ADD COLUMN "idempotencyKey" TEXT;

ALTER TABLE "rental_payments"
  ADD CONSTRAINT "rental_payments_recordedByEmployeeId_fkey"
  FOREIGN KEY ("recordedByEmployeeId") REFERENCES "employees"("id")
  ON DELETE SET NULL ON UPDATE CASCADE;

ALTER TABLE "rental_payments"
  ADD CONSTRAINT "rental_payments_companyId_idempotencyKey_key"
  UNIQUE ("companyId", "idempotencyKey");
