2023-04-18 06:24:44 +03:00
|
|
|
generator client {
|
|
|
|
provider = "prisma-client-js"
|
|
|
|
}
|
|
|
|
|
2023-06-21 09:08:32 +03:00
|
|
|
datasource db {
|
|
|
|
provider = "postgresql"
|
|
|
|
url = env("DATABASE_URL")
|
2023-04-18 06:24:44 +03:00
|
|
|
}
|
|
|
|
|
2023-04-28 02:02:05 +03:00
|
|
|
model Workspace {
|
|
|
|
id String @id @default(uuid()) @db.VarChar
|
|
|
|
public Boolean
|
|
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
|
|
|
users UserWorkspacePermission[]
|
|
|
|
|
|
|
|
@@map("workspaces")
|
2023-04-18 06:24:44 +03:00
|
|
|
}
|
|
|
|
|
2023-04-28 02:02:05 +03:00
|
|
|
model UserWorkspacePermission {
|
|
|
|
id String @id @default(uuid()) @db.VarChar
|
|
|
|
workspaceId String @map("workspace_id") @db.VarChar
|
|
|
|
userId String @map("entity_id") @db.VarChar
|
|
|
|
/// Read/Write/Admin/Owner
|
|
|
|
type Int @db.SmallInt
|
|
|
|
/// Whether the permission invitation is accepted by the user
|
|
|
|
accepted Boolean @default(false)
|
|
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
2023-06-21 09:08:32 +03:00
|
|
|
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
2023-04-28 02:02:05 +03:00
|
|
|
|
|
|
|
@@map("user_workspace_permissions")
|
2023-04-18 06:24:44 +03:00
|
|
|
}
|
2023-06-21 09:08:32 +03:00
|
|
|
|
|
|
|
model User {
|
|
|
|
id String @id @default(uuid()) @db.VarChar
|
|
|
|
name String
|
|
|
|
email String? @unique
|
|
|
|
emailVerified DateTime? @map("email_verified")
|
|
|
|
// image field is for the next-auth
|
|
|
|
avatarUrl String? @map("image") @db.VarChar
|
|
|
|
accounts Account[]
|
|
|
|
sessions Session[]
|
|
|
|
workspaces UserWorkspacePermission[]
|
|
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
|
|
|
/// Not available if user signed up through OAuth providers
|
|
|
|
password String? @db.VarChar
|
|
|
|
|
|
|
|
@@map("users")
|
|
|
|
}
|
|
|
|
|
|
|
|
model Account {
|
|
|
|
id String @id @default(cuid())
|
|
|
|
userId String @map("user_id")
|
|
|
|
type String
|
|
|
|
provider String
|
|
|
|
providerAccountId String @map("provider_account_id")
|
|
|
|
refresh_token String? @db.Text
|
|
|
|
access_token String? @db.Text
|
|
|
|
expires_at Int?
|
|
|
|
token_type String?
|
|
|
|
scope String?
|
|
|
|
id_token String? @db.Text
|
|
|
|
session_state String?
|
|
|
|
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
@@unique([provider, providerAccountId])
|
|
|
|
@@map("accounts")
|
|
|
|
}
|
|
|
|
|
|
|
|
model Session {
|
|
|
|
id String @id @default(cuid())
|
|
|
|
sessionToken String @unique @map("session_token")
|
|
|
|
userId String @map("user_id")
|
|
|
|
expires DateTime
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
|
|
|
|
@@map("sessions")
|
|
|
|
}
|
|
|
|
|
|
|
|
model VerificationToken {
|
|
|
|
identifier String
|
|
|
|
token String @unique
|
|
|
|
expires DateTime
|
|
|
|
|
|
|
|
@@unique([identifier, token])
|
|
|
|
@@map("verificationtokens")
|
|
|
|
}
|