umami/db/mysql/schema.prisma

134 lines
4.4 KiB
Plaintext
Raw Normal View History

2020-07-17 10:03:38 +02:00
generator client {
provider = "prisma-client-js"
}
datasource db {
2023-03-02 01:42:47 +01:00
provider = "mysql"
url = env("DATABASE_URL")
2023-01-05 20:13:49 +01:00
relationMode = "prisma"
2020-07-17 10:03:38 +02:00
}
2023-01-05 20:13:49 +01:00
model User {
2023-01-05 23:40:34 +01:00
id String @id @unique @map("user_id") @db.VarChar(36)
2023-01-05 20:13:49 +01:00
username String @unique @db.VarChar(255)
password String @db.VarChar(60)
role String @map("role") @db.VarChar(50)
2023-01-05 23:40:34 +01:00
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
deletedAt DateTime? @map("deleted_at") @db.Timestamp(0)
2023-01-05 20:13:49 +01:00
2023-03-02 01:42:47 +01:00
teamUser TeamUser[]
Website Website[]
2023-02-02 19:12:25 +01:00
teamWebsite TeamWebsite[]
2023-01-05 20:13:49 +01:00
@@map("user")
2020-07-23 05:45:09 +02:00
}
2023-01-05 20:13:49 +01:00
model Session {
2023-02-16 18:52:07 +01:00
id String @id @unique @map("session_id") @db.VarChar(36)
websiteId String @map("website_id") @db.VarChar(36)
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.Char(3)
subdivision2 String? @db.VarChar(50)
2023-02-16 18:52:07 +01:00
city String? @db.VarChar(50)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
2020-07-18 04:33:40 +02:00
@@index([createdAt])
@@index([websiteId])
2023-01-05 20:13:49 +01:00
@@map("session")
2020-07-17 10:03:38 +02:00
}
2023-01-05 20:13:49 +01:00
model Website {
2023-01-05 23:40:34 +01:00
id String @id @unique @map("website_id") @db.VarChar(36)
2023-01-05 20:13:49 +01:00
name String @db.VarChar(100)
domain String? @db.VarChar(500)
shareId String? @unique @map("share_id") @db.VarChar(50)
2023-01-05 23:40:34 +01:00
revId Int @default(0) @map("rev_id") @db.UnsignedInt
userId String? @map("user_id") @db.VarChar(36)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
deletedAt DateTime? @map("deleted_at") @db.Timestamp(0)
2023-01-05 20:13:49 +01:00
2023-03-02 01:42:47 +01:00
user User? @relation(fields: [userId], references: [id])
2023-02-02 19:12:25 +01:00
teamWebsite TeamWebsite[]
2023-01-05 20:13:49 +01:00
@@index([userId])
@@index([createdAt])
@@index([shareId])
@@map("website")
2022-07-30 07:30:09 +02:00
}
2023-01-05 20:13:49 +01:00
model WebsiteEvent {
2023-01-05 23:40:34 +01:00
id String @id() @map("event_id") @db.VarChar(36)
websiteId String @map("website_id") @db.VarChar(36)
sessionId String @map("session_id") @db.VarChar(36)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
url String @db.VarChar(500)
referrer String? @db.VarChar(500)
2023-02-15 18:40:49 +01:00
pageTitle String? @map("page_title") @db.VarChar(500)
2023-01-05 23:40:34 +01:00
eventType Int @default(1) @map("event_type") @db.UnsignedInt
2023-01-05 20:13:49 +01:00
eventName String? @map("event_name") @db.VarChar(50)
2020-07-18 04:33:40 +02:00
@@index([createdAt])
@@index([sessionId])
@@index([websiteId])
2023-01-05 20:13:49 +01:00
@@index([websiteId, createdAt])
@@index([websiteId, sessionId, createdAt])
2023-01-05 20:13:49 +01:00
@@map("website_event")
2020-07-17 10:03:38 +02:00
}
2023-01-05 20:13:49 +01:00
model Team {
2023-01-05 23:40:34 +01:00
id String @id() @unique() @map("team_id") @db.VarChar(36)
2023-01-05 20:13:49 +01:00
name String @db.VarChar(50)
2023-01-05 23:40:34 +01:00
userId String @map("user_id") @db.VarChar(36)
2023-01-05 20:13:49 +01:00
accessCode String? @unique @map("access_code") @db.VarChar(50)
2023-01-05 23:40:34 +01:00
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
2020-07-18 04:33:40 +02:00
2023-03-02 01:42:47 +01:00
teamUsers TeamUser[]
2023-02-02 19:12:25 +01:00
teamWebsite TeamWebsite[]
2023-01-05 20:13:49 +01:00
@@index([userId])
@@index([accessCode])
@@map("team")
2020-07-17 10:03:38 +02:00
}
2023-01-05 20:13:49 +01:00
model TeamUser {
2023-01-05 23:40:34 +01:00
id String @id() @unique() @map("team_user_id") @db.VarChar(36)
teamId String @map("team_id") @db.VarChar(36)
userId String @map("user_id") @db.VarChar(36)
2023-01-05 20:13:49 +01:00
role String @map("role") @db.VarChar(50)
2023-01-05 23:40:34 +01:00
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
updatedAt DateTime? @map("updated_at") @db.Timestamp(0)
2023-01-05 20:13:49 +01:00
team Team @relation(fields: [teamId], references: [id])
user User @relation(fields: [userId], references: [id])
2020-08-12 09:23:03 +02:00
2023-01-05 20:13:49 +01:00
@@index([teamId])
@@index([userId])
2023-01-05 20:13:49 +01:00
@@map("team_user")
2020-07-17 10:03:38 +02:00
}
2023-02-02 19:12:25 +01:00
model TeamWebsite {
id String @id() @unique() @map("team_website_id") @db.VarChar(36)
teamId String @map("team_id") @db.VarChar(36)
userId String @map("user_id") @db.VarChar(36)
websiteId String @map("website_id") @db.VarChar(36)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
2023-03-02 01:42:47 +01:00
team Team @relation(fields: [teamId], references: [id])
user User @relation(fields: [userId], references: [id])
2023-02-02 19:12:25 +01:00
website Website @relation(fields: [websiteId], references: [id])
@@index([teamId])
@@index([userId])
@@index([websiteId])
@@map("team_website")
}