2024-08-24 12:41:04 -06:00
|
|
|
generator client {
|
|
|
|
provider = "prisma-client-js"
|
|
|
|
}
|
|
|
|
|
|
|
|
datasource db {
|
|
|
|
provider = "postgresql"
|
|
|
|
url = env("CAIRO_POSTGRES_URI")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Models
|
|
|
|
model Project {
|
|
|
|
id String @id @default(cuid())
|
|
|
|
slug String @unique
|
|
|
|
parentProject String
|
|
|
|
name String?
|
|
|
|
users User[]
|
|
|
|
rolePolicies RolePolicy[]
|
|
|
|
keyPairs KeyPair[]
|
|
|
|
}
|
|
|
|
|
|
|
|
// User
|
|
|
|
model User {
|
|
|
|
id String @id @unique @default(cuid())
|
|
|
|
username String
|
|
|
|
email String?
|
|
|
|
hash String
|
|
|
|
rolePolicyId String
|
|
|
|
projectId String
|
|
|
|
|
|
|
|
// Relations
|
|
|
|
rolePolicy RolePolicy @relation(fields: [rolePolicyId], references: [id])
|
|
|
|
project Project @relation(fields: [projectId], references: [id])
|
|
|
|
|
|
|
|
// Unique constraints
|
|
|
|
@@unique([projectId, username])
|
|
|
|
@@unique([projectId, email])
|
|
|
|
}
|
|
|
|
|
|
|
|
model RolePolicy {
|
|
|
|
id String @id @default(cuid())
|
|
|
|
projectId String
|
|
|
|
authority String
|
|
|
|
authorityType AuthorityType @default(RolePolicy)
|
|
|
|
name String
|
|
|
|
policies String[]
|
|
|
|
|
|
|
|
// Relations
|
|
|
|
users User[]
|
|
|
|
project Project @relation(fields: [projectId], references: [id])
|
|
|
|
}
|
|
|
|
|
|
|
|
model KeyPair {
|
|
|
|
id String @id @default(cuid())
|
|
|
|
projectId String
|
|
|
|
usage KeyPairType // Application Level Uniqueness for non-custom usages. For example, there can only be 1 UserToken Keypair
|
|
|
|
name String?
|
|
|
|
encryptedPrivateKey String
|
|
|
|
encryptedPublicKey String
|
|
|
|
|
2024-12-23 00:57:35 +00:00
|
|
|
// Relations
|
|
|
|
project Project @relation(fields: [projectId], references: [id])
|
2024-08-24 12:41:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
enum AuthorityType {
|
|
|
|
Root
|
|
|
|
User
|
|
|
|
RolePolicy
|
|
|
|
}
|
|
|
|
|
|
|
|
enum KeyPairType {
|
|
|
|
UserToken
|
|
|
|
Custom
|
|
|
|
}
|