77 lines
1.5 KiB
Plaintext
77 lines
1.5 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"
|
|
output = "../generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id Int @id @default(autoincrement())
|
|
username String @unique
|
|
password String
|
|
owner Boolean
|
|
userPerms UserPerm[]
|
|
}
|
|
|
|
model Namespace {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
|
|
UserPerm UserPerm[]
|
|
AlarmGroup AlarmGroup[]
|
|
}
|
|
|
|
model UserPerm {
|
|
permission Permission
|
|
|
|
// User FK
|
|
userId Int
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
// Namespace FK
|
|
namespaceId Int
|
|
namespace Namespace @relation(fields: [namespaceId], references: [id])
|
|
|
|
@@id([userId, namespaceId])
|
|
}
|
|
|
|
enum Permission {
|
|
snoozer
|
|
shutter
|
|
manager
|
|
}
|
|
|
|
model AlarmGroup {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
state AlarmGroupState
|
|
|
|
// Namespace FK
|
|
NamespaceId Int
|
|
Namespace Namespace @relation(fields: [NamespaceId], references: [id])
|
|
Alarm Alarm[]
|
|
}
|
|
|
|
enum AlarmGroupState {
|
|
idle
|
|
handle
|
|
}
|
|
|
|
model Alarm {
|
|
id Int @id @default(autoincrement())
|
|
name String
|
|
|
|
// AlarmGroup FK
|
|
AlarmGroupId Int
|
|
AlarmGroup AlarmGroup @relation(fields: [AlarmGroupId], references: [id])
|
|
}
|