mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-18 12:21:41 +03:00
b4bb57b2a5
Co-authored-by: Himself65 <himself65@outlook.com>
64 lines
2.6 KiB
Plaintext
64 lines
2.6 KiB
Plaintext
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid()) @db.VarChar
|
|
name String @db.VarChar
|
|
email String @unique @db.VarChar
|
|
tokenNonce Int @default(0) @map("token_nonce") @db.SmallInt
|
|
avatarUrl String? @map("avatar_url") @db.VarChar
|
|
/// Available if user signed up through OAuth providers
|
|
password String? @db.VarChar
|
|
/// User may created by email collobration invitation before signup.
|
|
/// We will precreate a user entity in such senarios but leave fulfilled as false until they signed up
|
|
/// This implementation is convenient for handing unregistered user permissoin
|
|
fulfilled Boolean @default(true)
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
|
|
connectedAccounts ConnectedAccount[]
|
|
workspaces UserWorkspacePermission[]
|
|
|
|
@@map("users")
|
|
}
|
|
|
|
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")
|
|
}
|
|
|
|
model ConnectedAccount {
|
|
id String @id @default(uuid()) @db.VarChar
|
|
userId String @map("user_id")
|
|
/// the general provider name, e.g. google, github, facebook
|
|
provider String @db.VarChar
|
|
/// the user id provided by OAuth providers, or other user identitive credential like `username` provided by GitHub
|
|
providerUserId String @unique @map("provider_user_id") @db.VarChar
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("connected_accounts")
|
|
}
|
|
|
|
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)
|
|
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("user_workspace_permissions")
|
|
}
|