Files
portabase/prisma/schema.prisma
T
2024-12-17 20:24:11 +01:00

221 lines
6.8 KiB
Plaintext

//////////////////////////////////////////////////////////////////////////////////////////////
// DO NOT MODIFY THIS FILE //
// This file is automatically generated by ZenStack CLI and should not be manually updated. //
//////////////////////////////////////////////////////////////////////////////////////////////
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-openssl-3.0.x", "debian-openssl-3.0.x"]
}
enum Role {
pending
user
admin
}
enum Dbms {
postgresql
mysql
mongodb
}
enum Status {
waiting
ongoing
failed
success
}
enum TypeStorage {
local
s3
}
model Account {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
userId String @map("user_id")
type String
provider String
providerAccountId String @map("provider_account_id")
refresh_token String? @db.Text()
access_token String? @db.Text()
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text()
session_state String?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@map("accounts")
}
model Session {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
sessionToken String @unique() @map("session_token")
userId String @map("user_id")
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@map("sessions")
}
model VerificationToken {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
identifier String
token String
expires DateTime
@@unique([identifier, token])
@@map("verificationtokens")
}
model User {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
name String?
email String? @unique()
emailVerified DateTime? @map("email_verified")
image String?
role Role
password String?
authMethod String? @map("auth_method")
deleted Boolean? @default(false)
accounts Account[]
sessions Session[]
organizations UserOrganization[]
@@map("users")
}
model Organization {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
slug String @unique()
name String
projects Project[]
users UserOrganization[]
@@map("organizations")
}
model UserOrganization {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
userId String
organizationId String
user User @relation(fields: [userId], references: [id])
organization Organization @relation(fields: [organizationId], references: [id])
@@unique([userId, organizationId])
@@map("users_organisations")
}
model Project {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
slug String @unique()
name String
organizationId String @map("organization_id")
organization Organization @relation(fields: [organizationId], references: [id])
databases Database[]
@@map("projects")
}
model Agent {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
slug String @unique()
name String
description String?
lastContact DateTime? @map("last_contact")
databases Database[]
@@map("agents")
}
model Database {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
name String
dbms Dbms
generatedId String @unique()
description String?
backupPolicy String? @map("backup_policy")
isWaitingForBackup Boolean? @default(false)
backupToRestore String?
agentId String @map("agent_id")
agent Agent @relation(fields: [agentId], references: [id], onDelete: Cascade)
lastContact DateTime? @map("last_contact")
backups Backup[]
restorations Restoration[]
projectId String? @map("project_id")
project Project? @relation(fields: [projectId], references: [id])
@@map("databases")
}
model Backup {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
status Status @default(waiting)
file String?
databaseId String @map("database_id")
database Database @relation(fields: [databaseId], references: [id], onDelete: Cascade)
restorations Restoration[]
@@map("backups")
}
model Restoration {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
status Status @default(waiting)
backupId String @map("backup_id")
backup Backup @relation(fields: [backupId], references: [id], onDelete: Cascade)
databaseId String? @map("database_id")
database Database? @relation(fields: [databaseId], references: [id], onDelete: Cascade)
@@map("restorations")
}
model Settings {
id String @id() @default(cuid())
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime? @updatedAt() @map("updated_at")
storage TypeStorage @default(local)
name String @unique()
s3EndPointUrl String?
s3AccessKeyId String?
s3SecretAccessKey String?
S3BucketName String?
smtpPassword String?
smtpFrom String?
smtpHost String?
smtpPort String?
smtpUser String?
@@map("settings")
}