umami/db/postgresql/schema.prisma

218 lines
7.0 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")
}
2022-11-01 07:42:37 +01:00
model user {
id String @id @unique @map("user_id") @db.Uuid
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)
2022-11-01 07:42:37 +01:00
groupRole groupRole[]
groupUser groupUser[]
userRole userRole[]
teamWebsite teamWebsite[]
teamUser teamUser[]
userWebsite userWebsite[]
website website[]
2020-07-23 05:45:09 +02:00
}
2020-07-17 10:03:38 +02:00
model event {
2022-11-01 07:42:37 +01:00
id String @id() @map("event_id") @db.Uuid
websiteId String @map("website_id") @db.Uuid
sessionId String @map("session_id") @db.Uuid
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
url String @db.VarChar(500)
eventName String @map("event_name") @db.VarChar(50)
eventData eventData?
2020-07-18 04:33:40 +02:00
@@index([createdAt])
@@index([sessionId])
@@index([websiteId])
2022-08-01 21:22:17 +02:00
}
model eventData {
2022-11-01 07:42:37 +01:00
id String @id @unique @map("event_data_id") @db.Uuid
eventId String @unique @map("event_id") @db.Uuid
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 {
2022-11-01 07:42:37 +01:00
id String @id @unique @map("view_id") @db.Uuid
websiteId String @map("website_id") @db.Uuid
sessionId String @map("session_id") @db.Uuid
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
url String @db.VarChar(500)
referrer String? @db.VarChar(500)
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 {
2022-11-01 07:42:37 +01:00
id String @id @unique @map("session_id") @db.Uuid
websiteId String @map("website_id") @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)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
2020-07-18 04:33:40 +02:00
@@index([createdAt])
@@index([websiteId])
2020-07-17 10:03:38 +02:00
}
model website {
2022-11-01 07:42:37 +01:00
id String @id @unique @map("website_id") @db.Uuid
userId String @map("user_id") @db.Uuid
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)
user user @relation(fields: [userId], references: [id])
teamWebsite teamWebsite[]
userWebsite userWebsite[]
2020-08-12 09:23:03 +02:00
@@index([userId])
2022-11-01 07:42:37 +01:00
}
model group {
id String @id() @unique() @map("group_id") @db.Uuid
name String @unique() @db.VarChar(255)
description String? @db.VarChar(255)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
isDeleted Boolean @default(false) @map("is_deleted")
groupRoles groupRole[]
groupUsers groupUser[]
}
model groupRole {
id String @id() @unique() @map("group_role_id") @db.Uuid
groupId String @map("group_id") @db.Uuid
roleId String @map("role_id") @db.Uuid
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
isDeleted Boolean @default(false) @map("is_deleted")
group group @relation(fields: [groupId], references: [id])
role role @relation(fields: [roleId], references: [id])
user user? @relation(fields: [userId], references: [id])
userId String? @db.Uuid
@@map("group_role")
}
model groupUser {
id String @id() @unique() @map("group_user_id") @db.Uuid
groupId String @map("group_id") @db.Uuid
userId String @map("user_id") @db.Uuid
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
isDeleted Boolean @default(false) @map("is_deleted")
group group @relation(fields: [groupId], references: [id])
user user @relation(fields: [userId], references: [id])
@@map("group_user")
}
model permission {
id String @id() @unique() @map("permission_id") @db.Uuid
name String @unique() @db.VarChar(255)
description String? @db.VarChar(255)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
isDeleted Boolean @default(false) @map("is_deleted")
}
model role {
id String @id() @unique() @map("role_id") @db.Uuid
name String @unique() @db.VarChar(255)
description String? @db.VarChar(255)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
isDeleted Boolean @default(false) @map("is_deleted")
groupRoles groupRole[]
userRoles userRole[]
}
model userRole {
id String @id() @unique() @map("user_role_id") @db.Uuid
roleId String @map("role_id") @db.Uuid
userId String @map("user_id") @db.Uuid
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
isDeleted Boolean @default(false) @map("is_deleted")
role role @relation(fields: [roleId], references: [id])
user user @relation(fields: [userId], references: [id])
@@map("user_role")
}
model team {
id String @id() @unique() @map("team_id") @db.Uuid
name String @unique() @db.VarChar(50)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
isDeleted Boolean @default(false) @map("is_deleted")
teamWebsites teamWebsite[]
teamUsers teamUser[]
}
model teamWebsite {
id String @id() @unique() @map("team_website_id") @db.Uuid
teamId String @map("team_id") @db.Uuid
websiteId String @map("website_id") @db.Uuid
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
isDeleted Boolean @default(false) @map("is_deleted")
website website @relation(fields: [websiteId], references: [id])
team team @relation(fields: [teamId], references: [id])
user user? @relation(fields: [userId], references: [id])
userId String? @db.Uuid
@@map("team_website")
}
model teamUser {
id String @id() @unique() @map("team_user_id") @db.Uuid
teamId String @map("team_id") @db.Uuid
userId String @map("user_id") @db.Uuid
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
isDeleted Boolean @default(false) @map("is_deleted")
team team @relation(fields: [teamId], references: [id])
user user @relation(fields: [userId], references: [id])
@@map("team_user")
}
model userWebsite {
id String @id() @unique() @map("user_website_id") @db.Uuid
userId String @map("user_id") @db.Uuid
websiteId String @map("website_id") @db.Uuid
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
isDeleted Boolean @default(false) @map("is_deleted")
website website @relation(fields: [websiteId], references: [id])
user user @relation(fields: [userId], references: [id])
@@map("user_website")
2022-07-15 07:57:38 +02:00
}