-- CreateTable
CREATE TABLE "EntityUniqueVisitor" (
    "id" TEXT NOT NULL,
    "entityType" "AnalyticsEntityType" NOT NULL,
    "entityId" TEXT NOT NULL,
    "visitorId" TEXT NOT NULL,
    "firstSeenAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "lastSeenAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updatedAt" TIMESTAMP(3) NOT NULL,

    CONSTRAINT "EntityUniqueVisitor_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "EntityUniqueVisitor_entityType_entityId_idx" ON "EntityUniqueVisitor"("entityType", "entityId");

-- CreateIndex
CREATE INDEX "EntityUniqueVisitor_entityType_entityId_lastSeenAt_idx" ON "EntityUniqueVisitor"("entityType", "entityId", "lastSeenAt");

-- CreateIndex
CREATE UNIQUE INDEX "EntityUniqueVisitor_entityType_entityId_visitorId_key" ON "EntityUniqueVisitor"("entityType", "entityId", "visitorId");
