umami/db/mysql/schema.prisma
Brian Cao ba31f48f1a
Feat/um 49 query builder api (#1573)
* add uuid to event. add indexes

* eventdata api

* add event data

* remove test data

* update list
2022-10-21 21:33:23 -07:00

104 lines
3.7 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model account {
id Int @id @default(autoincrement()) @map("user_id") @db.UnsignedInt
username String @unique() @db.VarChar(255)
password String @db.VarChar(60)
isAdmin Boolean @default(false) @map("is_admin")
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
updatedAt DateTime? @default(now()) @map("updated_at") @db.Timestamp(0)
accountUuid String @unique() @map("account_uuid") @db.VarChar(36)
website website[]
@@index([accountUuid])
}
model event {
id Int @id @default(autoincrement()) @map("event_id") @db.UnsignedInt
websiteId Int @map("website_id") @db.UnsignedInt
sessionId Int @map("session_id") @db.UnsignedInt
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
url String @db.VarChar(500)
eventName String @map("event_name") @db.VarChar(50)
eventUuid String @unique() @map("event_uuid") @db.VarChar(36)
session session @relation(fields: [sessionId], references: [id])
website website @relation(fields: [websiteId], references: [id])
eventData eventData?
@@index([createdAt])
@@index([sessionId])
@@index([websiteId])
@@index([eventUuid])
}
model eventData {
id Int @id @default(autoincrement()) @map("event_data_id") @db.UnsignedInt
eventId Int @unique @map("event_id") @db.UnsignedInt
eventData Json @map("event_data")
event event @relation(fields: [eventId], references: [id])
@@map("event_data")
}
model pageview {
id Int @id @default(autoincrement()) @map("view_id") @db.UnsignedInt
websiteId Int @map("website_id") @db.UnsignedInt
sessionId Int @map("session_id") @db.UnsignedInt
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
url String @db.VarChar(500)
referrer String? @db.VarChar(500)
session session @relation(fields: [sessionId], references: [id])
website website @relation(fields: [websiteId], references: [id])
@@index([createdAt])
@@index([sessionId])
@@index([websiteId, createdAt])
@@index([websiteId])
@@index([websiteId, sessionId, createdAt])
}
model session {
id Int @id @default(autoincrement()) @map("session_id") @db.UnsignedInt
sessionUuid String @unique() @map("session_uuid") @db.VarChar(36)
websiteId Int @map("website_id") @db.UnsignedInt
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
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)
website website @relation(fields: [websiteId], references: [id])
event event[]
pageview pageview[]
@@index([createdAt])
@@index([websiteId])
@@index([sessionUuid])
}
model website {
id Int @id @default(autoincrement()) @map("website_id") @db.UnsignedInt
websiteUuid String @unique() @map("website_uuid") @db.VarChar(36)
userId Int @map("user_id") @db.UnsignedInt
name String @db.VarChar(100)
domain String? @db.VarChar(500)
shareId String? @unique() @map("share_id") @db.VarChar(64)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
account account @relation(fields: [userId], references: [id])
event event[]
pageview pageview[]
session session[]
@@index([userId])
@@index([websiteUuid])
}