Files
vfxreview/prisma/migrations/20260930010000_delivery_requests/migration.sql
T
twotalesanimation f30acef101
Deploy / deploy (push) Successful in 5m17s
feat(deliveries): delivery requests and upload/share evidence
A built package used to become DELIVERED on one click with nothing behind
it, and nothing recorded what a client had asked for.

- Marking delivered is now two recorded steps: Record upload (the link on
  the client's portal, contents confirmed) then Share link (who it was sent
  to). The second is refused until the first is on record.
- Delivery requests log a client's ask by episode, pasted shot codes or a
  Shot Status selection. A line closes only when its shot goes out with
  evidence after the request was logged; a request can otherwise only be
  cancelled with a reason.
- Delivered Outside Pipeline takes an upload link and recipient, required
  for shots on an open request.
- The dashboard gains an Awaiting delivery section listing open requests
  and built packages the client does not have yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 14:21:24 +02:00

45 lines
2.2 KiB
SQL

-- Delivery requests: what a client asked for, tracked until it has gone out
-- with evidence. Closure is derived from packages and manual deliveries, so
-- there is no status column to fall out of step.
CREATE TABLE "delivery_requests" (
"id" TEXT NOT NULL,
"projectId" TEXT NOT NULL,
"requestNumber" INTEGER NOT NULL,
"episode" TEXT NOT NULL DEFAULT '',
"deliverable" TEXT NOT NULL DEFAULT 'EXR',
"requestedBy" TEXT NOT NULL,
"note" TEXT,
"dueDate" TIMESTAMP(3),
"createdById" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"cancelledAt" TIMESTAMP(3),
"cancelledById" TEXT,
"cancelReason" TEXT,
CONSTRAINT "delivery_requests_pkey" PRIMARY KEY ("id")
);
CREATE TABLE "delivery_request_lines" (
"id" TEXT NOT NULL,
"requestId" TEXT NOT NULL,
"shotId" TEXT NOT NULL,
"shotCode" TEXT NOT NULL,
"clientCode" TEXT,
CONSTRAINT "delivery_request_lines_pkey" PRIMARY KEY ("id")
);
CREATE UNIQUE INDEX "delivery_requests_projectId_requestNumber_key" ON "delivery_requests"("projectId", "requestNumber");
CREATE INDEX "delivery_requests_projectId_cancelledAt_idx" ON "delivery_requests"("projectId", "cancelledAt");
CREATE UNIQUE INDEX "delivery_request_lines_requestId_shotId_key" ON "delivery_request_lines"("requestId", "shotId");
CREATE INDEX "delivery_request_lines_shotId_idx" ON "delivery_request_lines"("shotId");
ALTER TABLE "delivery_requests" ADD CONSTRAINT "delivery_requests_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "delivery_request_lines" ADD CONSTRAINT "delivery_request_lines_requestId_fkey" FOREIGN KEY ("requestId") REFERENCES "delivery_requests"("id") ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE "delivery_request_lines" ADD CONSTRAINT "delivery_request_lines_shotId_fkey" FOREIGN KEY ("shotId") REFERENCES "shots"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- A manual delivery closes a request line only with the same evidence a
-- package carries: where it was uploaded and who was sent the link.
ALTER TABLE "shots" ADD COLUMN "manualDeliveryUrl" TEXT;
ALTER TABLE "shots" ADD COLUMN "manualDeliverySharedWith" TEXT;