139 lines
3.4 KiB
Plaintext
139 lines
3.4 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Host {
|
|
id String @id @default(cuid())
|
|
hostname String @unique
|
|
lastUpdate DateTime @default(now())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
// Relations
|
|
records Record[]
|
|
credentials Credential[]
|
|
|
|
@@map("hosts")
|
|
}
|
|
|
|
model Record {
|
|
id String @id @default(cuid())
|
|
hostname String
|
|
timestamp DateTime @default(now())
|
|
isStarred Boolean @default(false)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
// Relations
|
|
host Host @relation(fields: [hostname], references: [hostname])
|
|
windows Window[]
|
|
screenshots Screenshot[]
|
|
|
|
@@index([hostname, timestamp])
|
|
@@index([timestamp])
|
|
@@index([isStarred])
|
|
@@map("records")
|
|
}
|
|
|
|
model Window {
|
|
id String @id @default(cuid())
|
|
recordId String
|
|
title String
|
|
path String
|
|
memory BigInt
|
|
|
|
// Relations
|
|
record Record @relation(fields: [recordId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("windows")
|
|
}
|
|
|
|
model Screenshot {
|
|
id String @id @default(cuid())
|
|
recordId String
|
|
fileId String // 保持兼容性
|
|
objectName String // MinIO 对象名称
|
|
filename String
|
|
monitorName String
|
|
contentType String @default("image/webp")
|
|
fileSize Int @default(0)
|
|
|
|
// Relations
|
|
record Record @relation(fields: [recordId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([objectName])
|
|
@@map("screenshots")
|
|
}
|
|
|
|
model Credential {
|
|
id String @id @default(cuid())
|
|
hostname String
|
|
username String
|
|
browser String
|
|
url String
|
|
login String
|
|
lastSyncTime DateTime @default(now())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
// Relations
|
|
host Host @relation(fields: [hostname], references: [hostname])
|
|
passwords Password[]
|
|
|
|
@@unique([hostname, username, browser, url, login])
|
|
@@index([hostname])
|
|
@@map("credentials")
|
|
}
|
|
|
|
model Password {
|
|
id String @id @default(cuid())
|
|
credentialId String
|
|
value String
|
|
timestamp DateTime @default(now())
|
|
|
|
// Relations
|
|
credential Credential @relation(fields: [credentialId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("passwords")
|
|
}
|
|
|
|
model Version {
|
|
id String @id @default(cuid())
|
|
version String
|
|
fileId String // 保持兼容性
|
|
objectName String // MinIO 对象名称
|
|
filename String
|
|
checksum String
|
|
contentType String @default("application/x-msdownload")
|
|
fileSize Int @default(0)
|
|
uploadTime DateTime @default(now())
|
|
isLatest Boolean @default(false)
|
|
|
|
@@index([objectName])
|
|
@@map("versions")
|
|
}
|
|
|
|
model Nssm {
|
|
id String @id @default(cuid())
|
|
fileId String // 保持兼容性
|
|
objectName String // MinIO 对象名称
|
|
filename String
|
|
checksum String
|
|
contentType String @default("application/x-msdownload")
|
|
fileSize Int @default(0)
|
|
uploadTime DateTime @default(now())
|
|
|
|
@@index([objectName])
|
|
@@map("nssm")
|
|
} |