feature(queue): use postgres instead of redis for buffer

* wip(buffer): initial implementation of psql buffer

* wip(buffer): add both profile and bots buffer
This commit is contained in:
Carl-Gerhard Lindesvärd
2025-01-29 15:17:54 +00:00
committed by Carl-Gerhard Lindesvärd
parent 2b5b8ce446
commit 71bf22af51
16 changed files with 19713 additions and 18747 deletions

View File

@@ -0,0 +1,24 @@
-- CreateTable
CREATE TABLE "event_buffer" (
"id" TEXT NOT NULL,
"projectId" TEXT NOT NULL,
"eventId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"profileId" TEXT,
"sessionId" TEXT,
"payload" JSONB NOT NULL,
"processedAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "event_buffer_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "event_buffer_eventId_key" ON "event_buffer"("eventId");
-- CreateIndex
CREATE INDEX "event_buffer_projectId_processedAt_createdAt_idx" ON "event_buffer"("projectId", "processedAt", "createdAt");
-- CreateIndex
CREATE INDEX "event_buffer_projectId_profileId_sessionId_createdAt_idx" ON "event_buffer"("projectId", "profileId", "sessionId", "createdAt");

View File

@@ -0,0 +1,22 @@
-- CreateTable
CREATE TABLE "profile_buffer" (
"id" TEXT NOT NULL,
"projectId" TEXT NOT NULL,
"profileId" TEXT NOT NULL,
"checksum" TEXT NOT NULL,
"payload" JSONB NOT NULL,
"processedAt" TIMESTAMP(3),
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "profile_buffer_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "profile_buffer_projectId_profileId_idx" ON "profile_buffer"("projectId", "profileId");
-- CreateIndex
CREATE INDEX "profile_buffer_projectId_processedAt_idx" ON "profile_buffer"("projectId", "processedAt");
-- CreateIndex
CREATE INDEX "profile_buffer_checksum_idx" ON "profile_buffer"("checksum");

View File

@@ -0,0 +1,17 @@
-- CreateTable
CREATE TABLE "bot_event_buffer" (
"id" TEXT NOT NULL,
"projectId" TEXT NOT NULL,
"eventId" TEXT NOT NULL,
"payload" JSONB NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"processedAt" TIMESTAMP(3),
CONSTRAINT "bot_event_buffer_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE INDEX "bot_event_buffer_processedAt_idx" ON "bot_event_buffer"("processedAt");
-- CreateIndex
CREATE INDEX "bot_event_buffer_projectId_eventId_idx" ON "bot_event_buffer"("projectId", "eventId");