fenghuo/packages/db/prisma/schema.prisma

136 lines
4.3 KiB
Plaintext
Raw Normal View History

2025-05-26 19:56:34 +08:00
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-1.1.x"]
output = "../generated/prisma"
}
datasource db {
provider = "postgres"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
name String
password String?
salt String?
phone String? @unique
email String @unique
avatar String?
isSystem Boolean? @map("is_system")
isAdmin Boolean? @map("is_admin")
lastSignTime DateTime? @map("last_sign_time")
deactivatedTime DateTime? @map("deactivated_time")
createdTime DateTime @default(now()) @map("created_time")
deletedTime DateTime? @map("deleted_time")
lastModifiedTime DateTime? @updatedAt @map("last_modified_time")
@@map("users")
}
model Attachments {
id String @id @default(cuid())
token String @unique
hash String
size Int
mimetype String
path String
width Int?
height Int?
deletedTime DateTime? @map("deleted_time")
createdTime DateTime @default(now()) @map("created_time")
createdBy String @map("created_by")
lastModifiedBy String? @map("last_modified_by")
thumbnailPath String? @map("thumbnail_path")
@@map("attachments")
}
model Notification {
id String @id @default(cuid())
fromUserId String @map("from_user_id")
toUserId String @map("to_user_id")
type String @map("type")
message String @map("message")
urlPath String? @map("url_path")
isRead Boolean @default(false) @map("is_read")
createdTime DateTime @default(now()) @map("created_time")
createdBy String @map("created_by")
@@index([toUserId, isRead, createdTime])
@@map("notification")
}
model Setting {
instanceId String @id @default(cuid()) @map("instance_id")
disallowSignUp Boolean? @map("disallow_sign_up")
disallowSpaceCreation Boolean? @map("disallow_space_creation")
disallowSpaceInvitation Boolean? @map("disallow_space_invitation")
enableEmailVerification Boolean? @map("enable_email_verification")
aiConfig String? @map("ai_config")
brandName String? @map("brand_name")
brandLogo String? @map("brand_logo")
@@map("setting")
}
model Trash {
id String @id @default(cuid())
resourceType String @map("resource_type")
resourceId String @map("resource_id")
parentId String? @map("parent_id")
deletedTime DateTime @default(now()) @map("deleted_time")
deletedBy String @map("deleted_by")
@@unique([resourceType, resourceId])
@@map("trash")
}
model UserLastVisit {
id String @id @default(cuid())
userId String @map("user_id")
resourceType String @map("resource_type")
resourceId String @map("resource_id")
parentResourceId String @map("parent_resource_id")
lastVisitTime DateTime @default(now()) @map("last_visit_time")
@@unique([userId, resourceType, parentResourceId])
@@index([userId, resourceType])
@@map("user_last_visit")
}
2025-05-26 22:25:28 +08:00
model OidcClient {
id String @id @default(cuid())
clientId String @unique
clientSecret String
redirectUris String // 存储为JSON字符串
grantTypes String // 存储为JSON字符串
responseTypes String // 存储为JSON字符串
scope String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("oidc_clients")
}
2025-05-28 08:23:15 +08:00
model Resource {
id String @id @default(cuid()) @map("id")
title String? @map("title")
description String? @map("description")
type String? @map("type")
fileId String? @unique
url String?
meta Json? @map("meta")
status String?
createdAt DateTime? @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt @map("updated_at")
createdBy String? @map("created_by")
updatedBy String? @map("updated_by")
deletedAt DateTime? @map("deleted_at")
isPublic Boolean? @default(true) @map("is_public")
storageType String? @map("storage_type")
// 索引
@@index([type])
@@index([createdAt])
@@map("resource")
}