// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model User { id String @id @default(cuid()) email String @unique name String? password String? image String? emailVerified DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt qrCodes QRCode[] integrations Integration[] accounts Account[] sessions Session[] } model Account { id String @id @default(cuid()) userId String type String provider String providerAccountId String refresh_token String? @db.Text access_token String? @db.Text expires_at Int? token_type String? scope String? id_token String? @db.Text session_state String? user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([provider, providerAccountId]) } model Session { id String @id @default(cuid()) sessionToken String @unique userId String expires DateTime user User @relation(fields: [userId], references: [id], onDelete: Cascade) } model VerificationToken { identifier String token String @unique expires DateTime @@unique([identifier, token]) } model QRCode { id String @id @default(cuid()) userId String title String type QRType @default(DYNAMIC) contentType ContentType @default(URL) content Json tags String[] status QRStatus @default(ACTIVE) style Json slug String @unique createdAt DateTime @default(now()) updatedAt DateTime @updatedAt user User @relation(fields: [userId], references: [id], onDelete: Cascade) scans QRScan[] @@index([userId, createdAt]) } enum QRType { STATIC DYNAMIC } enum ContentType { URL WIFI VCARD PHONE EMAIL SMS TEXT WHATSAPP } enum QRStatus { ACTIVE PAUSED } model QRScan { id String @id @default(cuid()) qrId String ts DateTime @default(now()) ipHash String userAgent String? device String? os String? country String? referrer String? utmSource String? utmMedium String? utmCampaign String? isUnique Boolean @default(false) qr QRCode @relation(fields: [qrId], references: [id], onDelete: Cascade) @@index([qrId, ts]) } model Integration { id String @id @default(cuid()) userId String provider String status String @default("inactive") config Json createdAt DateTime @default(now()) updatedAt DateTime @updatedAt user User @relation(fields: [userId], references: [id], onDelete: Cascade) }