1
1
mirror of https://github.com/ZeroCatDev/ClassworksKV.git synced 2026-02-03 23:23:10 +00:00
ClassworksKV/prisma/schema.prisma

91 lines
3.4 KiB
Plaintext

generator client {
provider = "prisma-client"
output = "../generated/prisma"
}
datasource db {
provider = "postgresql"
}
model Account {
id String @id(map: "idx_18303_PRIMARY") @db.VarChar(191) @default(cuid())
provider String @db.VarChar(191)
providerId String @db.VarChar(191)
email String? @db.VarChar(191)
name String? @db.VarChar(191)
avatarUrl String? @db.VarChar(191)
providerData Json? @db.Json
accessToken String?
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)
refreshToken String?
refreshTokenExpiry DateTime? @db.Timestamptz(6)
tokenVersion Int @default(1)
devices Device[]
@@unique([provider, providerId], map: "idx_18303_Account_provider_providerId_key")
}
model AppInstall {
id String @id(map: "idx_18310_PRIMARY") @default(cuid()) @db.VarChar(191)
deviceId Int
appId String @db.VarChar(191)
token String @unique(map: "idx_18310_AppInstall_token_key") @db.VarChar(191)
note String? @db.VarChar(191)
installedAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)
deviceType String? @db.VarChar(191)
isReadOnly Boolean @default(false)
device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade)
@@index([deviceId], map: "idx_18310_AppInstall_deviceId_fkey")
}
model AutoAuth {
id String @id(map: "idx_18317_PRIMARY") @default(cuid()) @db.VarChar(191)
deviceId Int
password String? @db.VarChar(191)
deviceType String? @db.VarChar(191)
isReadOnly Boolean @default(false)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)
device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade)
@@unique([deviceId, password], map: "idx_18317_AutoAuth_deviceId_password_key")
}
model Device {
id Int @id(map: "idx_18324_PRIMARY") @default(autoincrement())
uuid String @unique(map: "idx_18324_Device_uuid_key") @db.VarChar(191)
name String? @db.VarChar(191)
accountId String? @db.VarChar(191)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)
password String? @db.VarChar(191)
passwordHint String? @db.VarChar(191)
namespace String? @unique(map: "idx_18324_Device_namespace_key") @db.VarChar(191)
// 关联关系
account Account? @relation(fields: [accountId], references: [id], onDelete: SetNull)
appInstalls AppInstall[]
kvStore KVStore[] // 设备相关的KV存储
autoAuths AutoAuth[] // 自动授权配置
@@index([accountId], map: "idx_18324_Device_accountId_fkey")
}
model KVStore {
deviceId Int
key String @db.VarChar(191)
value Json @db.Json
creatorIp String? @default("") @db.VarChar(191)
createdAt DateTime @default(now()) @db.Timestamptz(6)
updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)
device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade)
@@id([deviceId, key], map: "idx_18330_PRIMARY")
}