49 lines
2.0 KiB
SQL
49 lines
2.0 KiB
SQL
CREATE TABLE IF NOT EXISTS "CanvasLayoutReplaceBatch" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"userId" uuid NOT NULL REFERENCES "User"("id") ON DELETE CASCADE,
|
|
"projectId" uuid NOT NULL REFERENCES "CanvasProject"("id") ON DELETE CASCADE,
|
|
"status" varchar(24) NOT NULL DEFAULT 'pending',
|
|
"referenceImageUrl" text NOT NULL,
|
|
"supplementalPrompt" text,
|
|
"imageSize" varchar(16) NOT NULL DEFAULT '2K',
|
|
"totalCount" integer NOT NULL,
|
|
"completedCount" integer NOT NULL DEFAULT 0,
|
|
"failedCount" integer NOT NULL DEFAULT 0,
|
|
"completedAt" timestamp,
|
|
"createdAt" timestamp NOT NULL DEFAULT now(),
|
|
"updatedAt" timestamp NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS "CanvasLayoutReplaceBatch_project_created_idx"
|
|
ON "CanvasLayoutReplaceBatch"("projectId", "createdAt");
|
|
|
|
CREATE INDEX IF NOT EXISTS "CanvasLayoutReplaceBatch_user_status_idx"
|
|
ON "CanvasLayoutReplaceBatch"("userId", "status");
|
|
|
|
CREATE TABLE IF NOT EXISTS "CanvasLayoutReplaceBatchItem" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"batchId" uuid NOT NULL REFERENCES "CanvasLayoutReplaceBatch"("id") ON DELETE CASCADE,
|
|
"taskId" uuid NOT NULL REFERENCES "CanvasImageTask"("id") ON DELETE CASCADE,
|
|
"position" integer NOT NULL,
|
|
"sourceNodeId" varchar(160),
|
|
"sourceImageUrl" text NOT NULL,
|
|
"sourceTitle" varchar(256),
|
|
"sourceKind" varchar(16) NOT NULL DEFAULT 'canvas',
|
|
"status" varchar(16) NOT NULL DEFAULT 'pending',
|
|
"resultImageUrl" text,
|
|
"resultThumbnailUrl" text,
|
|
"resultModelId" varchar(160),
|
|
"error" text,
|
|
"addedToCanvas" boolean NOT NULL DEFAULT false,
|
|
"addedCanvasNodeId" varchar(160),
|
|
"completedAt" timestamp,
|
|
"createdAt" timestamp NOT NULL DEFAULT now(),
|
|
"updatedAt" timestamp NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS "CanvasLayoutReplaceBatchItem_batch_position_idx"
|
|
ON "CanvasLayoutReplaceBatchItem"("batchId", "position");
|
|
|
|
CREATE INDEX IF NOT EXISTS "CanvasLayoutReplaceBatchItem_task_idx"
|
|
ON "CanvasLayoutReplaceBatchItem"("taskId");
|