28 lines
1007 B
SQL
28 lines
1007 B
SQL
CREATE TABLE IF NOT EXISTS "EnhanceProTask" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"userId" uuid NOT NULL REFERENCES "User"("id") ON DELETE cascade,
|
|
"chatId" uuid REFERENCES "Chat"("id") ON DELETE cascade,
|
|
"messageId" uuid,
|
|
"clientRequestId" varchar(64),
|
|
"providerTaskId" varchar(128) NOT NULL,
|
|
"taskKeyId" varchar(64),
|
|
"status" varchar(16) NOT NULL DEFAULT 'pending',
|
|
"prompt" text,
|
|
"sourceImageUrl" text NOT NULL,
|
|
"request" jsonb NOT NULL,
|
|
"result" jsonb,
|
|
"error" text,
|
|
"pointsCost" integer NOT NULL DEFAULT 0,
|
|
"pointsCharged" boolean NOT NULL DEFAULT false,
|
|
"chargedAt" timestamp,
|
|
"completedAt" timestamp,
|
|
"createdAt" timestamp NOT NULL DEFAULT now(),
|
|
"updatedAt" timestamp NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS "EnhanceProTask_providerTaskId_idx"
|
|
ON "EnhanceProTask" ("providerTaskId");
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS "EnhanceProTask_userId_clientRequestId_idx"
|
|
ON "EnhanceProTask" ("userId", "clientRequestId");
|