[INIT] Initial Project Structure
Some checks failed
Deploy Edge / deploy-edge (push) Failing after 2s
S3 Repo Backup / s3-repo-backup (push) Failing after 2s

This commit is contained in:
Dunemask 2024-08-24 12:41:04 -06:00
commit 0fc5f05b6a
105 changed files with 10448 additions and 0 deletions

73
prisma/schema.prisma Normal file
View file

@ -0,0 +1,73 @@
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
project Project @relation(fields: [projectId], references: [id])
// Application Level Uniqueness for non-custom usages. For example, there can only be 1 UserToken Keypair
}
enum AuthorityType {
Root
User
RolePolicy
}
enum KeyPairType {
UserToken
Custom
}