2023-09-02 12:13:50 +00:00
|
|
|
datasource db {
|
|
|
|
provider = "postgresql"
|
|
|
|
url = env("DATABASE_URL")
|
|
|
|
}
|
|
|
|
|
|
|
|
generator client {
|
2023-09-02 19:49:20 +00:00
|
|
|
provider = "prisma-client-js"
|
2023-09-02 12:13:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
model User {
|
2023-09-02 19:49:20 +00:00
|
|
|
id String @id @unique @default(uuid()) @db.Uuid
|
2023-09-02 12:13:50 +00:00
|
|
|
username String @unique @db.VarChar(255)
|
|
|
|
password String @db.VarChar(60)
|
|
|
|
role String @db.VarChar(50)
|
|
|
|
createdAt DateTime? @default(now()) @db.Timestamptz(6)
|
|
|
|
updatedAt DateTime? @updatedAt @db.Timestamptz(6)
|
|
|
|
deletedAt DateTime? @db.Timestamptz(6)
|
|
|
|
|
2023-09-02 19:49:20 +00:00
|
|
|
workspaces WorkspacesOnUsers[]
|
2023-09-02 12:13:50 +00:00
|
|
|
}
|
|
|
|
|
2023-09-02 19:49:20 +00:00
|
|
|
model Workspace {
|
|
|
|
id String @id @unique @default(uuid()) @db.Uuid
|
2023-09-02 12:13:50 +00:00
|
|
|
name String @db.VarChar(100)
|
|
|
|
createdAt DateTime? @default(now()) @db.Timestamptz(6)
|
|
|
|
updatedAt DateTime? @updatedAt @db.Timestamptz(6)
|
|
|
|
|
2023-09-02 19:49:20 +00:00
|
|
|
users WorkspacesOnUsers[]
|
|
|
|
website Website[]
|
|
|
|
}
|
|
|
|
|
|
|
|
model WorkspacesOnUsers {
|
|
|
|
userId String @db.Uuid
|
|
|
|
workspaceId String @db.Uuid
|
|
|
|
role String @db.VarChar(100)
|
|
|
|
createdAt DateTime? @default(now()) @db.Timestamptz(6)
|
|
|
|
updatedAt DateTime? @updatedAt @db.Timestamptz(6)
|
|
|
|
|
|
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
|
|
|
|
|
|
|
@@id([userId, workspaceId])
|
|
|
|
@@index([userId])
|
|
|
|
@@index([workspaceId])
|
|
|
|
}
|
|
|
|
|
|
|
|
model Website {
|
|
|
|
id String @id @unique @default(uuid()) @db.Uuid
|
|
|
|
name String @db.VarChar(100)
|
|
|
|
domain String? @db.VarChar(500)
|
|
|
|
shareId String? @unique @db.VarChar(50)
|
|
|
|
resetAt DateTime? @db.Timestamptz(6)
|
|
|
|
workspace Workspace @relation(fields: [workspaceId], references: [id])
|
|
|
|
workspaceId String @db.Uuid
|
|
|
|
createdAt DateTime? @default(now()) @db.Timestamptz(6)
|
|
|
|
updatedAt DateTime? @updatedAt @db.Timestamptz(6)
|
|
|
|
deletedAt DateTime? @db.Timestamptz(6)
|
|
|
|
|
2023-09-02 12:13:50 +00:00
|
|
|
eventData EventData[]
|
|
|
|
sessionData SessionData[]
|
|
|
|
|
2023-09-02 19:49:20 +00:00
|
|
|
@@index([workspaceId])
|
2023-09-02 12:13:50 +00:00
|
|
|
@@index([createdAt])
|
|
|
|
@@index([shareId])
|
|
|
|
}
|
|
|
|
|
|
|
|
model Session {
|
|
|
|
id String @id @unique @db.Uuid
|
|
|
|
websiteId String @db.Uuid
|
|
|
|
hostname String? @db.VarChar(100)
|
|
|
|
browser String? @db.VarChar(20)
|
|
|
|
os String? @db.VarChar(20)
|
|
|
|
device String? @db.VarChar(20)
|
|
|
|
screen String? @db.VarChar(11)
|
|
|
|
language String? @db.VarChar(35)
|
|
|
|
country String? @db.Char(2)
|
|
|
|
subdivision1 String? @db.VarChar(20)
|
|
|
|
subdivision2 String? @db.VarChar(50)
|
|
|
|
city String? @db.VarChar(50)
|
|
|
|
createdAt DateTime? @default(now()) @db.Timestamptz(6)
|
|
|
|
|
|
|
|
websiteEvent WebsiteEvent[]
|
|
|
|
sessionData SessionData[]
|
|
|
|
|
|
|
|
@@index([createdAt])
|
|
|
|
@@index([websiteId])
|
|
|
|
@@index([websiteId, createdAt])
|
|
|
|
@@index([websiteId, createdAt, hostname])
|
|
|
|
@@index([websiteId, createdAt, browser])
|
|
|
|
@@index([websiteId, createdAt, os])
|
|
|
|
@@index([websiteId, createdAt, device])
|
|
|
|
@@index([websiteId, createdAt, screen])
|
|
|
|
@@index([websiteId, createdAt, language])
|
|
|
|
@@index([websiteId, createdAt, country])
|
|
|
|
@@index([websiteId, createdAt, subdivision1])
|
|
|
|
@@index([websiteId, createdAt, city])
|
|
|
|
}
|
|
|
|
|
|
|
|
model WebsiteEvent {
|
|
|
|
id String @id() @db.Uuid
|
|
|
|
websiteId String @db.Uuid
|
|
|
|
sessionId String @db.Uuid
|
|
|
|
createdAt DateTime? @default(now()) @db.Timestamptz(6)
|
|
|
|
urlPath String @db.VarChar(500)
|
|
|
|
urlQuery String? @db.VarChar(500)
|
|
|
|
referrerPath String? @db.VarChar(500)
|
|
|
|
referrerQuery String? @db.VarChar(500)
|
|
|
|
referrerDomain String? @db.VarChar(500)
|
|
|
|
pageTitle String? @db.VarChar(500)
|
|
|
|
eventType Int @default(1) @db.Integer
|
|
|
|
eventName String? @db.VarChar(50)
|
|
|
|
|
|
|
|
eventData EventData[]
|
|
|
|
session Session @relation(fields: [sessionId], references: [id])
|
|
|
|
|
|
|
|
@@index([createdAt])
|
|
|
|
@@index([sessionId])
|
|
|
|
@@index([websiteId])
|
|
|
|
@@index([websiteId, createdAt])
|
|
|
|
@@index([websiteId, createdAt, urlPath])
|
|
|
|
@@index([websiteId, createdAt, urlQuery])
|
|
|
|
@@index([websiteId, createdAt, referrerDomain])
|
|
|
|
@@index([websiteId, createdAt, pageTitle])
|
|
|
|
@@index([websiteId, createdAt, eventName])
|
|
|
|
@@index([websiteId, sessionId, createdAt])
|
|
|
|
}
|
|
|
|
|
|
|
|
model EventData {
|
|
|
|
id String @id() @db.Uuid
|
|
|
|
websiteId String @db.Uuid
|
|
|
|
websiteEventId String @db.Uuid
|
|
|
|
eventKey String @db.VarChar(500)
|
|
|
|
stringValue String? @db.VarChar(500)
|
|
|
|
numberValue Decimal? @db.Decimal(19, 4)
|
|
|
|
dateValue DateTime? @db.Timestamptz(6)
|
|
|
|
dataType Int @db.Integer
|
|
|
|
createdAt DateTime? @default(now()) @db.Timestamptz(6)
|
|
|
|
|
|
|
|
website Website @relation(fields: [websiteId], references: [id])
|
|
|
|
websiteEvent WebsiteEvent @relation(fields: [websiteEventId], references: [id])
|
|
|
|
|
|
|
|
@@index([createdAt])
|
|
|
|
@@index([websiteId])
|
|
|
|
@@index([websiteEventId])
|
|
|
|
@@index([websiteId, createdAt])
|
|
|
|
@@index([websiteId, createdAt, eventKey])
|
|
|
|
}
|
|
|
|
|
|
|
|
model SessionData {
|
|
|
|
id String @id() @db.Uuid
|
|
|
|
websiteId String @db.Uuid
|
|
|
|
sessionId String @db.Uuid
|
|
|
|
sessionKey String @db.VarChar(500)
|
|
|
|
stringValue String? @db.VarChar(500)
|
|
|
|
numberValue Decimal? @db.Decimal(19, 4)
|
|
|
|
dateValue DateTime? @db.Timestamptz(6)
|
|
|
|
dataType Int @db.Integer
|
|
|
|
createdAt DateTime? @default(now()) @db.Timestamptz(6)
|
|
|
|
deletedAt DateTime? @default(now()) @db.Timestamptz(6)
|
|
|
|
|
|
|
|
website Website @relation(fields: [websiteId], references: [id])
|
|
|
|
session Session @relation(fields: [sessionId], references: [id])
|
|
|
|
|
|
|
|
@@index([createdAt])
|
|
|
|
@@index([websiteId])
|
|
|
|
@@index([sessionId])
|
|
|
|
}
|