umami/db/mysql/schema.prisma
2022-08-16 21:03:02 -07:00

95 lines
3.5 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model account {
user_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
username String @unique() @db.VarChar(255)
password String @db.VarChar(60)
is_admin Boolean @default(false)
created_at DateTime? @default(now()) @db.Timestamp(0)
updated_at DateTime? @default(now()) @db.Timestamp(0)
website website[]
}
model event {
event_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
website_id BigInt @db.UnsignedBigInt
session_id BigInt @db.UnsignedBigInt
created_at DateTime? @default(now()) @db.Timestamp(0)
url String @db.VarChar(500)
event_name String @db.VarChar(50)
session session @relation(fields: [session_id], references: [session_id], onDelete: Cascade, onUpdate: NoAction, map: "event_ibfk_2")
website website @relation(fields: [website_id], references: [website_id], onDelete: Cascade, onUpdate: NoAction, map: "event_ibfk_1")
event_data event_data?
@@index([created_at])
@@index([session_id])
@@index([website_id])
}
model event_data {
event_data_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
event_id BigInt @unique @db.UnsignedBigInt
event_data Json
event event @relation(fields: [event_id], references: [event_id])
}
model pageview {
view_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
website_id BigInt @db.UnsignedBigInt
session_id BigInt @db.UnsignedBigInt
created_at DateTime? @default(now()) @db.Timestamp(0)
url String @db.VarChar(500)
referrer String? @db.VarChar(500)
session session @relation(fields: [session_id], references: [session_id], onDelete: Cascade, onUpdate: NoAction, map: "pageview_ibfk_2")
website website @relation(fields: [website_id], references: [website_id], onDelete: Cascade, onUpdate: NoAction, map: "pageview_ibfk_1")
@@index([created_at])
@@index([session_id])
@@index([website_id, created_at])
@@index([website_id])
@@index([website_id, session_id, created_at])
}
model session {
session_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
session_uuid String @unique() @db.VarChar(36)
website_id BigInt @db.UnsignedBigInt
created_at DateTime? @default(now()) @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: [website_id], references: [website_id], onDelete: Cascade, onUpdate: NoAction, map: "session_ibfk_1")
event event[]
pageview pageview[]
@@index([created_at])
@@index([website_id])
}
model website {
website_id BigInt @id @default(autoincrement()) @db.UnsignedBigInt
website_uuid String @unique() @db.VarChar(36)
user_id BigInt @db.UnsignedBigInt
name String @db.VarChar(100)
domain String? @db.VarChar(500)
share_id String? @unique() @db.VarChar(64)
created_at DateTime? @default(now()) @db.Timestamp(0)
account account @relation(fields: [user_id], references: [user_id], onDelete: Cascade, onUpdate: NoAction, map: "website_ibfk_1")
event event[]
pageview pageview[]
session session[]
@@index([user_id])
}