simplehub / server /prisma /schema.prisma
jwy87
修复一些问题
89887b8
Raw History Blame Contribute Delete
4.53 kB
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-3.0.x", "linux-arm64-openssl-3.0.x", "linux-musl-openssl-3.0.x", "linux-musl-arm64-openssl-3.0.x"]
}
datasource db {
provider = "sqlite"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
email String @unique
passwordHash String
isAdmin Boolean @default(false)
createdAt DateTime @default(now())
}
model Site {
id String @id @default(cuid())
name String
baseUrl String
apiKeyEnc String
apiType String @default("other")
userId String?
billingUrl String?
billingAuthType String @default("token")
billingAuthValue String?
proxyUrlEnc String?
billingLimitField String?
billingUsageField String?
unlimitedQuota Boolean @default(false)
enableCheckIn Boolean @default(false)
checkInMode String @default("both")
scheduleCron String?
timezone String @default("UTC")
pinned Boolean @default(false)
excludeFromBatch Boolean @default(false)
categoryId String?
category Category? @relation(fields: [categoryId], references: [id])
extralink String?
remark String?
sortOrder Int @default(0)
lastCheckedAt DateTime?
createdAt DateTime @default(now())
snapshots ModelSnapshot[]
diffs ModelDiff[]
@@index([categoryId])
@@index([pinned, sortOrder, createdAt])
}
model ModelSnapshot {
id String @id @default(cuid())
siteId String
site Site @relation(fields: [siteId], references: [id])
fetchedAt DateTime @default(now())
modelsJson String
hash String
rawResponse String?
errorMessage String?
statusCode Int?
responseTime Int?
billingLimit Float? // system_hard_limit_usd from /v1/dashboard/billing/subscription
billingUsage Float? // total_usage * 0.01 from /v1/dashboard/billing/usage
billingError String? // billing查询错误信息(如果有)
checkInSuccess Boolean? // 签到是否成功(null表示未签到)
checkInMessage String? // 签到消息
checkInQuota Float? // 签到获得的额度
checkInError String? // 签到错误信息
diffsFrom ModelDiff[] @relation("SnapshotFrom")
diffsTo ModelDiff[] @relation("SnapshotTo")
@@index([siteId, fetchedAt])
@@index([siteId, errorMessage, fetchedAt])
}
model ModelDiff {
id String @id @default(cuid())
siteId String
site Site @relation(fields: [siteId], references: [id])
diffAt DateTime @default(now())
addedJson String
removedJson String
changedJson String
snapshotFromId String?
snapshotFrom ModelSnapshot? @relation("SnapshotFrom", fields: [snapshotFromId], references: [id])
snapshotToId String?
snapshotTo ModelSnapshot? @relation("SnapshotTo", fields: [snapshotToId], references: [id])
@@index([siteId, diffAt])
}
model EmailConfig {
id String @id @default(cuid())
resendApiKeyEnc String
notifyEmails String
enabled Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model ScheduleConfig {
id String @id @default(cuid())
enabled Boolean @default(false) // 是否启用定时检测
hour Int @default(9) // 小时 (0-23)
minute Int @default(0) // 分钟 (0-59)
timezone String @default("Asia/Shanghai") // 时区
interval Int @default(30) // 站点间检测间隔(秒)
overrideIndividual Boolean @default(false) // 是否覆盖站点单独配置
lastRun DateTime? // 上次运行时间
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Category {
id String @id @default(cuid())
name String @unique
scheduleCron String?
timezone String @default("Asia/Shanghai")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
sites Site[]
}