Files
twenty/server/src/database/schema.prisma
T
Charles BochetandGitHub 3674365e6f Scope server with workspace (#157)
* Rename User to AuthUser to avoid naming conflict with user business entity

* Prevent query by workspace in graphql

* Make full user and workspace object available in graphql resolvers

* Add Seed to create companies and people accross two workspace

* Check workspace on all entities findMany, find, create, update)
2023-05-30 20:40:04 +02:00

123 lines
3.2 KiB
Plaintext

generator client {
provider = "prisma-client-js"
engineType = "binary"
}
datasource db {
provider = "postgresql"
url = env("PG_DATABASE_URL")
}
generator nestgraphql {
provider = "node node_modules/prisma-nestjs-graphql"
output = "../../src/api/@generated"
}
model User {
id String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
lastSeen DateTime?
disabled Boolean @default(false)
displayName String
email String @unique
avatarUrl String?
locale String
phoneNumber String?
passwordHash String?
emailVerified Boolean @default(false)
metadata Json?
WorkspaceMember WorkspaceMember?
companies Company[]
RefreshTokens RefreshToken[]
@@map("users")
}
/// @TypeGraphQL.omit(input: true)
model Workspace {
id String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
domainName String @unique
displayName String
logo String?
WorkspaceMember WorkspaceMember[]
companies Company[]
people Person[]
@@map("workspaces")
}
model WorkspaceMember {
id String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
userId String @unique
user User @relation(fields: [userId], references: [id])
/// @TypeGraphQL.omit(input: true)
workspaceId String
/// @TypeGraphQL.omit(input: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
@@map("workspace_members")
}
model Company {
id String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
name String
domainName String
address String
employees Int?
accountOwnerId String?
accountOwner User? @relation(fields: [accountOwnerId], references: [id])
people Person[]
/// @TypeGraphQL.omit(input: true)
workspaceId String
/// @TypeGraphQL.omit(input: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
@@map("companies")
}
model Person {
id String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
firstname String
lastname String
email String
phone String
city String
companyId String?
company Company? @relation(fields: [companyId], references: [id])
/// @TypeGraphQL.omit(input: true)
workspaceId String
/// @TypeGraphQL.omit(input: true)
workspace Workspace @relation(fields: [workspaceId], references: [id])
@@map("people")
}
/// @TypeGraphQL.omit(input: true)
model RefreshToken {
id String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deletedAt DateTime?
refreshToken String
userId String
user User @relation(fields: [userId], references: [id])
@@map("refresh_tokens")
}