@varaos/db 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varaos/db",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "files": [
@@ -0,0 +1,22 @@
1
+ -- CreateTable
2
+ CREATE TABLE "public"."Visitor" (
3
+ "id" TEXT NOT NULL,
4
+ "visitorId" TEXT NOT NULL,
5
+ "ipAddress" TEXT,
6
+ "userAgent" TEXT,
7
+ "country" TEXT,
8
+ "referrer" TEXT,
9
+ "firstVisit" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
10
+ "lastVisit" TIMESTAMP(3) NOT NULL,
11
+ "visitCount" INTEGER NOT NULL DEFAULT 1,
12
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
13
+ "updatedAt" TIMESTAMP(3) NOT NULL,
14
+
15
+ CONSTRAINT "Visitor_pkey" PRIMARY KEY ("id")
16
+ );
17
+
18
+ -- CreateIndex
19
+ CREATE UNIQUE INDEX "Visitor_visitorId_key" ON "public"."Visitor"("visitorId");
20
+
21
+ -- CreateIndex
22
+ CREATE INDEX "Visitor_createdAt_idx" ON "public"."Visitor"("createdAt");
@@ -561,3 +561,25 @@ model Onboarding {
561
561
 
562
562
  user User @relation(fields: [userId], references: [id], onDelete: Cascade)
563
563
  }
564
+
565
+
566
+
567
+ /////////////////////
568
+ // Unique Visitors
569
+ //////////////////////
570
+ model Visitor {
571
+ id String @id @default(uuid())
572
+ visitorId String @unique // cookie or fingerprint ID
573
+ ipAddress String?
574
+ userAgent String?
575
+ country String? // optional if you plan to use GeoIP later
576
+ referrer String?
577
+ firstVisit DateTime @default(now())
578
+ lastVisit DateTime @updatedAt
579
+ visitCount Int @default(1)
580
+
581
+ createdAt DateTime @default(now())
582
+ updatedAt DateTime @updatedAt
583
+
584
+ @@index([createdAt])
585
+ }