[INIT] Initial Project Structure
This commit is contained in:
commit
0fc5f05b6a
105 changed files with 10448 additions and 0 deletions
73
prisma/schema.prisma
Normal file
73
prisma/schema.prisma
Normal 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue