feat: new importer (#214)
This commit is contained in:
committed by
GitHub
parent
b51bc8f3f6
commit
212254d31a
@@ -0,0 +1,22 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "public"."imports" (
|
||||
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
||||
"projectId" TEXT NOT NULL,
|
||||
"provider" TEXT NOT NULL,
|
||||
"sourceType" TEXT NOT NULL,
|
||||
"sourceLocation" TEXT NOT NULL,
|
||||
"jobId" TEXT,
|
||||
"status" TEXT NOT NULL,
|
||||
"config" JSONB NOT NULL DEFAULT '{}',
|
||||
"totalEvents" INTEGER NOT NULL DEFAULT 0,
|
||||
"processedEvents" INTEGER NOT NULL DEFAULT 0,
|
||||
"errorMessage" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"completedAt" TIMESTAMP(3),
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "imports_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "public"."imports" ADD CONSTRAINT "imports_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "public"."projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- You are about to drop the column `provider` on the `imports` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `sourceLocation` on the `imports` table. All the data in the column will be lost.
|
||||
- You are about to drop the column `sourceType` on the `imports` table. All the data in the column will be lost.
|
||||
|
||||
*/
|
||||
-- AlterTable
|
||||
ALTER TABLE "public"."imports" DROP COLUMN "provider",
|
||||
DROP COLUMN "sourceLocation",
|
||||
DROP COLUMN "sourceType",
|
||||
ALTER COLUMN "config" DROP DEFAULT;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "public"."imports" ADD COLUMN "statusMessage" TEXT;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "public"."imports" ADD COLUMN "currentBatch" INTEGER NOT NULL DEFAULT 0,
|
||||
ADD COLUMN "currentStep" TEXT;
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Changed the type of `status` on the `imports` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
|
||||
- Made the column `currentStep` on table `imports` required. This step will fail if there are existing NULL values in that column.
|
||||
|
||||
*/
|
||||
-- CreateEnum
|
||||
CREATE TYPE "public"."ImportStatus" AS ENUM ('pending', 'processing', 'completed', 'failed');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "public"."imports" DROP COLUMN "status",
|
||||
ADD COLUMN "status" "public"."ImportStatus" NOT NULL,
|
||||
ALTER COLUMN "currentStep" SET NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "public"."imports" ALTER COLUMN "currentStep" DROP NOT NULL;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "public"."imports" ALTER COLUMN "currentBatch" DROP NOT NULL,
|
||||
ALTER COLUMN "currentBatch" DROP DEFAULT,
|
||||
ALTER COLUMN "currentBatch" SET DATA TYPE TEXT;
|
||||
@@ -194,6 +194,7 @@ model Project {
|
||||
|
||||
notificationRules NotificationRule[]
|
||||
notifications Notification[]
|
||||
imports Import[]
|
||||
|
||||
// When deleteAt > now(), the project will be deleted
|
||||
deleteAt DateTime?
|
||||
@@ -467,3 +468,31 @@ model ResetPassword {
|
||||
|
||||
@@map("reset_password")
|
||||
}
|
||||
|
||||
enum ImportStatus {
|
||||
pending
|
||||
processing
|
||||
completed
|
||||
failed
|
||||
}
|
||||
|
||||
model Import {
|
||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
projectId String
|
||||
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||||
jobId String? // BullMQ job ID
|
||||
status ImportStatus
|
||||
statusMessage String? // Human-readable current step like "Importing events (Feb 2025)", "Generating session IDs"
|
||||
errorMessage String?
|
||||
/// [IPrismaImportConfig]
|
||||
config Json
|
||||
totalEvents Int @default(0)
|
||||
processedEvents Int @default(0)
|
||||
currentStep String?
|
||||
currentBatch String? // String date 2020-01-01
|
||||
createdAt DateTime @default(now())
|
||||
completedAt DateTime?
|
||||
updatedAt DateTime @default(now()) @updatedAt
|
||||
|
||||
@@map("imports")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user