ifms-pti/server/prisma/schema.prisma
2022-06-03 12:54:39 +00:00

196 lines
5.0 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model ResetToken {
id Int @id @default(autoincrement())
token String @unique
expiration DateTime
usedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
userId Int
user User @relation("resettoken_to_user", fields: [userId], references: [id])
creatorId Int
creator User @relation("resettoken_to_creator", fields: [creatorId], references: [id])
}
model User {
id Int @id @default(autoincrement())
lastLogin DateTime?
lastLoginPrior DateTime?
roles Json?
groups Json?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
accountExpires String?
badPasswordTime String?
badPwdCount String?
cn String?
department String?
description String?
displayName String?
distinguishedName String?
dn String?
extensionAttribute1 String?
extensionAttribute10 String?
extensionAttribute2 String?
extensionAttribute6 String?
extensionAttribute7 String?
givenName String?
homeDirectory String?
homeDrive String?
lastLogoff String?
lastLogon String?
lastLogonTimestamp String?
lockoutTime String?
logonCount String?
mail String?
name String?
objectCategory String?
objectGUID String?
objectSid String?
primaryGroupID String?
pwdLastSet DateTime?
sAMAccountName String @unique
sAMAccountType String?
sn String?
thumbnailPhoto String?
title String?
userAccountControl String?
userPrincipalName String?
whenChanged String?
whenCreated String?
createdTokens ResetToken[] @relation("resettoken_to_creator")
tokens ResetToken[] @relation("resettoken_to_user")
wifiDevices WifiDevice[] @relation("wifidevice_to_user")
ownedWifiDevices WifiDevice[] @relation("wifidevice_to_owner")
PAHost PAHost[] @relation("pahost_to_user")
}
model WifiDevice {
id Int @id @default(autoincrement())
oui String?
mac String @unique
hostname String?
firstSeen DateTime? @default(now())
lastSeen DateTime?
ip String?
name String?
notes String?
essid String?
uptime String?
apName String?
signalStrength Int?
frequency String?
protocol String?
speed Int?
usage Int?
status Status?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
controller String @default("unknown")
identity String? // The user informed by the controller
accessPointId Int?
accessPoint AccessPoint? @relation("wifidevice_to_ap", fields: [accessPointId], references: [id])
userId Int? // The connected User
user User? @relation("wifidevice_to_user", fields: [userId], references: [id])
ownerId Int? // The owner of the device
owner User? @relation("wifidevice_to_owner", fields: [ownerId], references: [id])
}
enum Status {
ONLINE
RECENT
OFFLINE
}
model Log {
id Int @id @default(autoincrement())
timestamp DateTime @default(now())
level LogLevel @default(LOW)
tags String?
message String
data Json?
}
enum LogLevel {
LOW
INFO
SUCCESS
WARNING
ERROR
}
model PAHost {
id Int @id @default(autoincrement())
user String
description String
cidr String @unique
encryptedKey String
note String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ownerId Int
owner User @relation("pahost_to_user", fields: [ownerId], references: [id])
}
model AccessPoint {
id Int @id @default(autoincrement())
mac String @unique
hostname String @unique
name String?
local String?
notes String?
inventoryTag String?
uptime String?
controller String?
model String?
ip String?
clients Int?
sshUser String?
sshPassword String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
wifiDevices WifiDevice[] @relation("wifidevice_to_ap")
stats WifiStats[] @relation("wifistats_to_ap")
}
model WifiStats {
id Int @id @default(autoincrement())
timestamp DateTime @default(now())
clients Int
accessPointId Int
accessPoint AccessPoint? @relation("wifistats_to_ap", fields: [accessPointId], references: [id])
}
model Network {
id Int @id @default(autoincrement())
name String @unique
shortName String @unique
cidr String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}