umami/db/postgresql/schema.prisma

104 lines
3.5 KiB
Plaintext
Raw Normal View History

2020-07-17 10:03:38 +02:00
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
2020-07-23 05:45:09 +02:00
model account {
id Int @id @default(autoincrement()) @map("user_id")
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.Timestamptz(6)
updatedAt DateTime? @default(now()) @map("updated_at") @db.Timestamptz(6)
accountUuid String @unique @map("account_uuid") @db.Uuid
website website[]
@@index([accountUuid])
2020-07-23 05:45:09 +02:00
}
2020-07-17 10:03:38 +02:00
model event {
id Int @id() @default(autoincrement()) @map("event_id")
websiteId Int @map("website_id")
sessionId Int @map("session_id")
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
url String @db.VarChar(500)
eventName String @map("event_name") @db.VarChar(50)
eventUuid String @unique @map("event_uuid") @db.Uuid
session session @relation(fields: [sessionId], references: [id])
website website @relation(fields: [websiteId], references: [id])
eventData eventData?
2020-07-18 04:33:40 +02:00
@@index([createdAt])
@@index([sessionId])
@@index([websiteId])
@@index([eventUuid])
2022-08-01 21:22:17 +02:00
}
model eventData {
id Int @id @default(autoincrement()) @map("event_data_id")
eventId Int @unique @map("event_id")
eventData Json @map("event_data")
event event @relation(fields: [eventId], references: [id])
@@map("event_data")
2022-07-28 02:13:53 +02:00
}
2020-07-17 10:03:38 +02:00
model pageview {
id Int @id @default(autoincrement()) @map("view_id")
websiteId Int @map("website_id")
sessionId Int @map("session_id")
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
url String @db.VarChar(500)
referrer String? @db.VarChar(500)
session session @relation(fields: [sessionId], references: [id])
website website @relation(fields: [websiteId], references: [id])
2020-07-18 04:33:40 +02:00
@@index([createdAt])
@@index([sessionId])
@@index([websiteId, createdAt])
@@index([websiteId])
@@index([websiteId, sessionId, createdAt])
2020-07-17 10:03:38 +02:00
}
model session {
id Int @id @default(autoincrement()) @map("session_id")
sessionUuid String @unique @map("session_uuid") @db.Uuid
websiteId Int @map("website_id")
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
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])
events event[]
pageview pageview[]
2020-07-18 04:33:40 +02:00
@@index([createdAt])
@@index([websiteId])
@@index([sessionUuid])
2020-07-17 10:03:38 +02:00
}
model website {
id Int @id @default(autoincrement()) @map("website_id")
websiteUuid String @unique @map("website_uuid") @db.Uuid
userId Int @map("user_id")
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.Timestamptz(6)
account account @relation(fields: [userId], references: [id])
event event[]
pageview pageview[]
session session[]
2020-08-12 09:23:03 +02:00
@@index([userId])
@@index([websiteUuid])
2022-07-15 07:57:38 +02:00
}