Scheduling infrastructure for absolutely everyone.
feat: Add spam block schema and migration (#23996)
Syed Ali Shahbaz4413295b2755
diff --git a/packages/prisma/migrations/20250923082416_add_spam_block/migration.sql b/packages/prisma/migrations/20250923082416_add_spam_block/migration.sqlnew file mode 100644index 00000000000..c8814cae4ec--- /dev/null+++ b/packages/prisma/migrations/20250923082416_add_spam_block/migration.sql@@ -0,0 +1,52 @@+/*+ Warnings:++ - A unique constraint covering the columns `[type,value,organizationId]` on the table `Watchlist` will be added. If there are existing duplicate values, this will fail.++*/+-- CreateEnum+CREATE TYPE "WatchlistAction" AS ENUM ('REPORT', 'BLOCK');++-- DropIndex+DROP INDEX "Watchlist_type_value_idx";++-- DropIndex+DROP INDEX "Watchlist_type_value_key";++-- AlterTable+ALTER TABLE "Watchlist" ADD COLUMN "action" "WatchlistAction" NOT NULL DEFAULT 'REPORT',+ADD COLUMN "organizationId" INTEGER;++-- CreateTable+CREATE TABLE "BlockedBookingLog" (+ "id" TEXT NOT NULL,+ "email" TEXT NOT NULL,+ "eventTypeId" INTEGER,+ "organizationId" INTEGER,+ "bookingData" JSONB,+ "watchlistId" TEXT,+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,++ CONSTRAINT "BlockedBookingLog_pkey" PRIMARY KEY ("id")+);++-- CreateIndex+CREATE INDEX "BlockedBookingLog_organizationId_createdAt_idx" ON "BlockedBookingLog"("organizationId", "createdAt");++-- CreateIndex+CREATE INDEX "BlockedBookingLog_email_idx" ON "BlockedBookingLog"("email");++-- CreateIndex+CREATE INDEX "BlockedBookingLog_watchlistId_idx" ON "BlockedBookingLog"("watchlistId");++-- CreateIndex+CREATE INDEX "Watchlist_type_value_organizationId_action_idx" ON "Watchlist"("type", "value", "organizationId", "action");++-- CreateIndex+CREATE UNIQUE INDEX "Watchlist_type_value_organizationId_key" ON "Watchlist"("type","value","organizationId");++-- CreateIndex+-- Enforce uniqueness for global entries (organizationId IS NULL)+CREATE UNIQUE INDEX "Watchlist_type_value_global_key"+ ON "Watchlist"("type","value")+ WHERE "organizationId" IS NULL;diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prismaindex 6f08cb9cd66..71a60d98d69 100644--- a/packages/prisma/schema.prisma+++ b/packages/prisma/schema.prisma@@ -2248,22 +2248,47 @@ enum WatchlistSeverity {CRITICAL}+enum WatchlistAction {+ REPORT+ BLOCK+}+model Watchlist {- id String @id @unique @default(cuid())- type WatchlistType- // The identifier of the Watchlisted entity (email or domain)+ id String @id @unique @default(cuid())+ type WatchlistType+value Stringdescription String?++ organizationId Int?++ action WatchlistAction @default(REPORT)+ severity WatchlistSeverity @default(LOW)createdAt DateTime @default(now())- createdBy User @relation("CreatedWatchlists", onDelete: Cascade, fields: [createdById], references: [id])+ createdBy User @relation("CreatedWatchlists", onDelete: SetNull, fields: [createdById], references: [id])createdById IntupdatedAt DateTime @updatedAtupdatedBy User? @relation("UpdatedWatchlists", onDelete: SetNull, fields: [updatedById], references: [id])updatedById Int?- severity WatchlistSeverity @default(LOW)- @@unique([type, value])- @@index([type, value])+ @@unique([type, value, organizationId])+ @@index([type, value, organizationId, action])+}++model BlockedBookingLog {+ id String @id @default(uuid())+ email String+ eventTypeId Int?++ organizationId Int?++ bookingData Json?+ createdAt DateTime @default(now())+ watchlistId String?++ @@index([organizationId, createdAt])+ @@index([email])+ @@index([watchlistId])}enum BillingPeriod {