Add PostgreSQL-backed background worker
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
CREATE TABLE IF NOT EXISTS "beenvoice_background_job" (
|
||||
"id" varchar(255) PRIMARY KEY NOT NULL,
|
||||
"type" varchar(100) NOT NULL,
|
||||
"payload" jsonb DEFAULT '{}'::jsonb NOT NULL,
|
||||
"status" varchar(20) DEFAULT 'pending' NOT NULL,
|
||||
"idempotencyKey" varchar(500) NOT NULL,
|
||||
"runAt" timestamp DEFAULT now() NOT NULL,
|
||||
"attempts" integer DEFAULT 0 NOT NULL,
|
||||
"maxAttempts" integer DEFAULT 5 NOT NULL,
|
||||
"lockedAt" timestamp,
|
||||
"lockedBy" varchar(255),
|
||||
"lastError" text,
|
||||
"completedAt" timestamp,
|
||||
"createdAt" timestamp DEFAULT now() NOT NULL,
|
||||
"updatedAt" timestamp DEFAULT now() NOT NULL,
|
||||
CONSTRAINT "beenvoice_background_job_idempotencyKey_unique" UNIQUE("idempotencyKey")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "background_job_status_run_at_idx" ON "beenvoice_background_job" USING btree ("status", "runAt");
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "background_job_type_status_idx" ON "beenvoice_background_job" USING btree ("type", "status");
|
||||
Reference in New Issue
Block a user