23 lines
857 B
SQL
23 lines
857 B
SQL
CREATE TABLE IF NOT EXISTS "ImageArchiveTask" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"sourceUrl" text NOT NULL UNIQUE,
|
|
"targetUrl" text,
|
|
"targetStorageConfigId" uuid REFERENCES "StorageConfig"("id"),
|
|
"status" varchar(32) NOT NULL DEFAULT 'pending',
|
|
"attemptCount" integer NOT NULL DEFAULT 0,
|
|
"lastError" text,
|
|
"archiveAfterAt" timestamp NOT NULL,
|
|
"replaceAfterAt" timestamp NOT NULL,
|
|
"archivedAt" timestamp,
|
|
"replacedAt" timestamp,
|
|
"metadata" jsonb,
|
|
"createdAt" timestamp NOT NULL DEFAULT now(),
|
|
"updatedAt" timestamp NOT NULL DEFAULT now()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS "ImageArchiveTask_status_archive_idx"
|
|
ON "ImageArchiveTask"("status", "archiveAfterAt", "createdAt");
|
|
|
|
CREATE INDEX IF NOT EXISTS "ImageArchiveTask_status_replace_idx"
|
|
ON "ImageArchiveTask"("status", "replaceAfterAt", "createdAt");
|