@@ -0,0 +1,32 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "footage_plates" (
|
||||
"id" TEXT NOT NULL,
|
||||
"shotId" TEXT NOT NULL,
|
||||
"label" TEXT NOT NULL DEFAULT '',
|
||||
"fileUrl" TEXT NOT NULL,
|
||||
"fileKey" TEXT NOT NULL DEFAULT '',
|
||||
"fileName" TEXT NOT NULL DEFAULT '',
|
||||
"fileSize" BIGINT,
|
||||
"sortOrder" INTEGER NOT NULL DEFAULT 0,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "footage_plates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "footage_plates" ADD CONSTRAINT "footage_plates_shotId_fkey" FOREIGN KEY ("shotId") REFERENCES "shots"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- Migrate existing single-footage data into footage_plates
|
||||
INSERT INTO "footage_plates" ("id", "shotId", "label", "fileUrl", "fileKey", "fileName", "fileSize", "sortOrder", "createdAt")
|
||||
SELECT
|
||||
gen_random_uuid()::text,
|
||||
id,
|
||||
'Plate A',
|
||||
"originalFootageUrl",
|
||||
COALESCE("originalFootageKey", ''),
|
||||
'',
|
||||
NULL,
|
||||
0,
|
||||
NOW()
|
||||
FROM "shots"
|
||||
WHERE "originalFootageUrl" IS NOT NULL AND "originalFootageUrl" != '';
|
||||
Reference in New Issue
Block a user