umami/db/postgresql/schema.prisma

200 lines
6.4 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-10 20:08:40 +01:00
model User {
2022-11-01 07:42:37 +01:00
id String @id @unique @map("user_id") @db.Uuid
username String @unique @db.VarChar(255)
password String @db.VarChar(60)
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
2022-11-18 07:27:33 +01:00
isDeleted Boolean @default(false) @map("is_deleted")
2022-11-20 09:48:13 +01:00
groupRole GroupRole[]
groupUser GroupUser[]
userRole UserRole[]
teamUser TeamUser[]
2022-11-22 01:44:42 +01:00
Website Website[]
2022-11-10 20:58:43 +01:00
@@map("user")
2020-07-23 05:45:09 +02:00
}
2022-11-10 20:08:40 +01: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])
2022-11-10 20:58:43 +01:00
@@map("session")
2020-07-17 10:03:38 +02:00
}
2022-11-10 20:08:40 +01:00
model Website {
2022-11-01 07:42:37 +01:00
id String @id @unique @map("website_id") @db.Uuid
name String @db.VarChar(100)
domain String? @db.VarChar(500)
shareId String? @unique @map("share_id") @db.VarChar(64)
revId Int @default(0) @map("rev_id") @db.Integer
2022-11-20 09:48:13 +01:00
userId String? @map("user_id") @db.Uuid
teamId String? @map("team_id") @db.Uuid
2022-11-01 07:42:37 +01:00
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
2022-11-05 00:15:26 +01:00
isDeleted Boolean @default(false) @map("is_deleted")
2022-11-01 07:42:37 +01:00
2022-11-22 01:44:42 +01:00
team Team? @relation(fields: [teamId], references: [id])
user User? @relation(fields: [userId], references: [id])
2020-08-12 09:23:03 +02:00
2022-11-05 00:15:26 +01:00
@@index([createdAt])
@@index([shareId])
2022-11-10 20:58:43 +01:00
@@map("website")
2022-11-05 00:15:26 +01:00
}
2022-11-10 20:08:40 +01:00
model WebsiteEvent {
2022-11-05 00:15:26 +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)
referrer String? @db.VarChar(500)
2022-11-15 22:21:14 +01:00
eventType Int @default(1) @map("event_type") @db.Integer
eventName String? @map("event_name") @db.VarChar(50)
eventData Json? @map("event_data")
2022-11-05 00:15:26 +01:00
@@index([createdAt])
@@index([sessionId])
@@index([websiteId])
@@index([websiteId, createdAt])
@@index([websiteId, sessionId, createdAt])
2022-11-10 20:08:40 +01:00
@@map("website_event")
2022-11-01 07:42:37 +01:00
}
2022-11-10 20:08:40 +01:00
model Group {
2022-11-01 07:42:37 +01:00
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")
2022-11-10 20:08:40 +01:00
groupRoles GroupRole[]
groupUsers GroupUser[]
2022-11-10 20:58:43 +01:00
@@map("group")
2022-11-01 07:42:37 +01:00
}
2022-11-10 20:08:40 +01:00
model GroupRole {
2022-11-01 07:42:37 +01:00
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")
2022-11-10 20:08:40 +01:00
group Group @relation(fields: [groupId], references: [id])
role Role @relation(fields: [roleId], references: [id])
user User? @relation(fields: [userId], references: [id])
2022-11-01 07:42:37 +01:00
userId String? @db.Uuid
@@map("group_role")
}
2022-11-10 20:08:40 +01:00
model GroupUser {
2022-11-01 07:42:37 +01:00
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")
2022-11-10 20:08:40 +01:00
group Group @relation(fields: [groupId], references: [id])
2022-11-16 19:32:02 +01:00
user User @relation(fields: [userId], references: [id])
2022-11-01 07:42:37 +01:00
@@map("group_user")
}
2022-11-10 20:08:40 +01:00
model Permission {
2022-11-18 07:27:33 +01:00
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)
RolePermission RolePermission[]
2022-11-10 20:58:43 +01:00
@@map("permission")
2022-11-01 07:42:37 +01:00
}
2022-11-10 20:08:40 +01:00
model Role {
2022-11-01 07:42:37 +01:00
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)
2022-11-18 07:27:33 +01:00
groupRoles GroupRole[]
userRoles UserRole[]
RolePermission RolePermission[]
2022-11-28 22:08:48 +01:00
TeamUser TeamUser[]
2022-11-10 20:58:43 +01:00
@@map("role")
2022-11-01 07:42:37 +01:00
}
2022-11-18 07:27:33 +01:00
model RolePermission {
id String @id() @unique() @map("role_permission_id") @db.Uuid
roleId String @map("role_id") @db.Uuid
permissionId String @map("permission_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])
permission Permission @relation(fields: [permissionId], references: [id])
2022-11-20 09:48:13 +01:00
@@unique([roleId, permissionId])
2022-11-18 07:27:33 +01:00
@@map("role_permission")
}
2022-11-10 20:08:40 +01:00
model UserRole {
2022-11-01 07:42:37 +01:00
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")
2022-11-28 22:08:48 +01:00
role Role @relation(fields: [roleId], references: [id])
user User @relation(fields: [userId], references: [id])
2022-11-01 07:42:37 +01:00
2022-11-28 22:08:48 +01:00
@@unique([roleId, userId])
2022-11-01 07:42:37 +01:00
@@map("user_role")
}
2022-11-10 20:08:40 +01:00
model Team {
2022-11-01 07:42:37 +01:00
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")
2022-11-20 09:48:13 +01:00
teamUsers TeamUser[]
2022-11-22 01:44:42 +01:00
Website Website[]
2022-11-10 20:58:43 +01:00
@@map("team")
2022-11-01 07:42:37 +01:00
}
2022-11-10 20:08:40 +01:00
model TeamUser {
2022-11-01 07:42:37 +01:00
id String @id() @unique() @map("team_user_id") @db.Uuid
teamId String @map("team_id") @db.Uuid
userId String @map("user_id") @db.Uuid
2022-11-28 22:08:48 +01:00
roleId String @map("role_id") @db.Uuid
2022-11-01 07:42:37 +01:00
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
isDeleted Boolean @default(false) @map("is_deleted")
2022-11-10 20:08:40 +01:00
team Team @relation(fields: [teamId], references: [id])
user User @relation(fields: [userId], references: [id])
2022-11-28 22:08:48 +01:00
role Role @relation(fields: [roleId], references: [id])
2022-11-01 07:42:37 +01:00
@@map("team_user")
}