Files
2023-03-22 15:11:37 +00:00

855 lines
20 KiB
Plaintext

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
output = "../node_modules/.prisma/client"
binaryTargets = ["native", "debian-openssl-1.1.x"]
previewFeatures = ["orderByNulls"]
}
model User {
id String @id @default(cuid())
email String @unique
authenticationMethod AuthenticationMethod
accessToken String?
authenticationProfile Json?
authenticationExtraParams Json?
displayName String?
name String?
avatarUrl String?
admin Boolean @default(false)
isOnCloudWaitlist Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
organizations Organization[]
gitHubAppAuthorizations GitHubAppAuthorization[]
featureCloud Boolean @default(false)
isOnHostedRepoWaitlist Boolean @default(false)
currentEnvironments CurrentEnvironment[]
}
enum AuthenticationMethod {
GITHUB
MAGIC_LINK
}
model Organization {
id String @id @default(cuid())
slug String @unique
title String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
users User[]
workflows Workflow[]
environments RuntimeEnvironment[]
apiConnections APIConnection[]
events TriggerEvent[]
externalSources ExternalSource[]
eventRules EventRule[]
schedulerSources SchedulerSource[]
internalSources InternalSource[]
templates OrganizationTemplate[]
repositoryProjects RepositoryProject[]
}
model APIConnection {
id String @id @default(cuid())
title String
apiIdentifier String
status APIConnectionStatus @default(CREATED)
scopes String[]
authenticationMethod APIAuthenticationMethod @default(OAUTH)
authenticationConfig Json?
type APIConnectionType
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
organizationId String
externalSources ExternalSource[]
externalServices ExternalService[]
}
enum APIAuthenticationMethod {
OAUTH
API_KEY
}
enum APIConnectionType {
HTTP
GRAPHQL
}
enum APIConnectionStatus {
CREATED
CONNECTED
}
model RuntimeEnvironment {
id String @id @default(cuid())
slug String
apiKey String @unique
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
organizationId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
events TriggerEvent[]
runs WorkflowRun[]
eventRules EventRule[]
schedulerSources SchedulerSource[]
internalSources InternalSource[]
deployments ProjectDeployment[]
keyValueItems KeyValueItem[]
currentEnvironments CurrentEnvironment[]
@@unique([organizationId, slug])
}
model Workflow {
id String @id @default(cuid())
slug String
title String
packageJson Json?
jsonSchema Json?
metadata Json?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
organizationId String
type TriggerType
status WorkflowStatus @default(CREATED)
externalSource ExternalSource? @relation(fields: [externalSourceId], references: [id], onDelete: Cascade, onUpdate: Cascade)
externalSourceId String?
runs WorkflowRun[]
rules EventRule[]
externalServices ExternalService[]
schedulerSources SchedulerSource[]
internalSources InternalSource[]
service String @default("trigger")
eventNames String[]
disabledAt DateTime?
archivedAt DateTime?
isArchived Boolean @default(false)
triggerTtlInSeconds Int @default(3600)
organizationTemplate OrganizationTemplate? @relation(fields: [organizationTemplateId], references: [id], onDelete: Cascade, onUpdate: Cascade)
organizationTemplateId String?
repositoryProject RepositoryProject? @relation(fields: [repositoryProjectId], references: [id], onDelete: Cascade, onUpdate: Cascade)
repositoryProjectId String?
currentEnvironments CurrentEnvironment[]
@@unique([organizationId, slug])
}
model EventRule {
id String @id @default(cuid())
type TriggerType
workflow Workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade, onUpdate: Cascade)
workflowId String
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
organizationId String
environment RuntimeEnvironment @relation(fields: [environmentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
environmentId String
filter Json
trigger Json
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
enabled Boolean @default(true)
runs WorkflowRun[]
@@unique([workflowId, environmentId])
}
enum TriggerType {
WEBHOOK
SCHEDULE
CUSTOM_EVENT
HTTP_ENDPOINT
EVENT_BRIDGE
HTTP_POLLING
SLACK_INTERACTION
}
enum WorkflowStatus {
CREATED
READY
DISABLED
}
model ExternalSource {
id String @id @default(cuid())
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
organizationId String
service String
workflows Workflow[]
type ExternalSourceType
key String
source Json
status ExternalSourceStatus @default(CREATED)
externalData Json?
secret String?
manualRegistration Boolean @default(false)
readyAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
connection APIConnection? @relation(fields: [connectionId], references: [id], onDelete: SetNull)
connectionId String?
@@unique([organizationId, key])
}
enum ExternalSourceStatus {
CREATED
READY
CANCELLED
}
enum ExternalSourceType {
WEBHOOK
EVENT_BRIDGE
HTTP_POLLING
}
model SchedulerSource {
id String @id @default(cuid())
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
organizationId String
workflow Workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade, onUpdate: Cascade)
workflowId String
environment RuntimeEnvironment @relation(fields: [environmentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
environmentId String
schedule Json
status SchedulerSourceStatus @default(CREATED)
readyAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([workflowId, environmentId])
}
enum SchedulerSourceStatus {
CREATED
READY
CANCELLED
}
// We should eventually move SchedulerSource to this as it's more generic
model InternalSource {
id String @id @default(cuid())
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
organizationId String
workflow Workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade, onUpdate: Cascade)
workflowId String
environment RuntimeEnvironment @relation(fields: [environmentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
environmentId String
type InternalSourceType
source Json
status InternalSourceStatus @default(CREATED)
readyAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([workflowId, environmentId])
}
enum InternalSourceType {
SLACK
}
enum InternalSourceStatus {
CREATED
READY
CANCELLED
}
model ExternalService {
id String @id @default(cuid())
slug String
service String
workflow Workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade, onUpdate: Cascade)
workflowId String
connection APIConnection? @relation(fields: [connectionId], references: [id], onDelete: SetNull)
connectionId String?
type ExternalServiceType
status ExternalServiceStatus @default(CREATED)
readyAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
requests IntegrationRequest[]
@@unique([workflowId, slug])
}
enum ExternalServiceType {
HTTP_API
}
enum ExternalServiceStatus {
CREATED
READY
}
model IntegrationRequest {
id String @id @default(cuid())
params Json
endpoint String
version String @default("1")
externalService ExternalService @relation(fields: [externalServiceId], references: [id], onDelete: Cascade, onUpdate: Cascade)
externalServiceId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
status IntegrationRequestStatus @default(PENDING)
run WorkflowRun @relation(fields: [runId], references: [id], onDelete: Cascade, onUpdate: Cascade)
runId String
step WorkflowRunStep @relation(fields: [stepId], references: [id], onDelete: Cascade, onUpdate: Cascade)
stepId String @unique
retryCount Int @default(0)
error Json?
response Json?
responses IntegrationResponse[]
}
enum IntegrationRequestStatus {
PENDING
WAITING_FOR_CONNECTION
FETCHING
RETRYING
SUCCESS
ERROR
}
model IntegrationResponse {
id String @id @default(cuid())
request IntegrationRequest @relation(fields: [requestId], references: [id], onDelete: Cascade, onUpdate: Cascade)
requestId String
output Json
context Json
createdAt DateTime @default(now())
}
model DurableDelay {
id String @id @default(cuid())
run WorkflowRun @relation(fields: [runId], references: [id], onDelete: Cascade, onUpdate: Cascade)
runId String
step WorkflowRunStep @relation(fields: [stepId], references: [id], onDelete: Cascade, onUpdate: Cascade)
stepId String @unique
delayUntil DateTime
createdAt DateTime @default(now())
resolvedAt DateTime?
}
model TriggerEvent {
id String @id @default(cuid())
service String
name String
type TriggerType
timestamp DateTime @default(now())
payload Json
context Json?
organization Organization? @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
organizationId String?
environment RuntimeEnvironment? @relation(fields: [environmentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
environmentId String?
status TriggerEventStatus @default(PENDING)
WorkflowRun WorkflowRun[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
dispatchedAt DateTime?
isTest Boolean @default(false)
}
enum TriggerEventStatus {
PENDING
DISPATCHED
}
model WorkflowRun {
id String @id @default(cuid())
workflow Workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade, onUpdate: Cascade)
workflowId String
environment RuntimeEnvironment @relation(fields: [environmentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
environmentId String
eventRule EventRule @relation(fields: [eventRuleId], references: [id], onDelete: Cascade, onUpdate: Cascade)
eventRuleId String
tasks WorkflowRunStep[]
event TriggerEvent @relation(fields: [eventId], references: [id], onDelete: Cascade, onUpdate: Cascade)
eventId String
error Json?
status WorkflowRunStatus @default(PENDING)
attemptCount Int @default(0)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
startedAt DateTime?
finishedAt DateTime?
timedOutAt DateTime?
timedOutReason String?
isTest Boolean @default(false)
requests IntegrationRequest[]
delays DurableDelay[]
fetchRequests FetchRequest[]
}
enum WorkflowRunStatus {
PENDING
RUNNING
DISCONNECTED
SUCCESS
ERROR
TIMED_OUT
}
model WorkflowRunStep {
id String @id @default(cuid())
run WorkflowRun @relation(fields: [runId], references: [id], onDelete: Cascade, onUpdate: Cascade)
runId String
idempotencyKey String
ts String
type WorkflowRunStepType
input Json?
output Json?
context Json
displayProperties Json?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
startedAt DateTime?
finishedAt DateTime?
status WorkflowRunStepStatus @default(PENDING)
integrationRequest IntegrationRequest?
delay DurableDelay?
fetchRequest FetchRequest?
@@unique([runId, idempotencyKey])
}
enum WorkflowRunStepStatus {
PENDING
RUNNING
SUCCESS
ERROR
}
enum WorkflowRunStepType {
OUTPUT
LOG_MESSAGE
DURABLE_DELAY
CUSTOM_EVENT
INTEGRATION_REQUEST
DISCONNECTION
FETCH_REQUEST
RUN_ONCE
KV_GET
KV_SET
KV_DELETE
}
model KeyValueItem {
id String @id @default(cuid())
key String
value Json
environment RuntimeEnvironment @relation(fields: [environmentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
environmentId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([environmentId, key])
}
model FetchRequest {
id String @id @default(cuid())
fetch Json
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
status FetchRequestStatus @default(PENDING)
run WorkflowRun @relation(fields: [runId], references: [id], onDelete: Cascade, onUpdate: Cascade)
runId String
step WorkflowRunStep @relation(fields: [stepId], references: [id], onDelete: Cascade, onUpdate: Cascade)
stepId String @unique
retryCount Int @default(0)
error Json?
response Json?
responses FetchResponse[]
}
enum FetchRequestStatus {
PENDING
FETCHING
RETRYING
SUCCESS
ERROR
}
model FetchResponse {
id String @id @default(cuid())
request FetchRequest @relation(fields: [requestId], references: [id], onDelete: Cascade, onUpdate: Cascade)
requestId String
output Json
context Json
createdAt DateTime @default(now())
}
model GitHubAppAuthorizationAttempt {
id String @id @default(cuid())
userId String
redirectTo String @default("/")
authorization GitHubAppAuthorization? @relation(fields: [authorizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
authorizationId String?
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
}
model GitHubAppAuthorization {
id String @id @default(cuid())
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
userId String
accountType GitHubAccountType @default(USER)
accountName String
installationId Int @unique
account Json
permissions Json
repositorySelection String
accessTokensUrl String
repositoriesUrl String
htmlUrl String
events String[]
installationAccessToken String?
installationAccessTokenExpiresAt DateTime?
organizationTemplates OrganizationTemplate[]
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
GitHubAppAuthorizationAttempt GitHubAppAuthorizationAttempt[]
repositoryProjects RepositoryProject[]
}
enum GitHubAccountType {
USER
ORGANIZATION
}
model RepositoryProject {
id String @id @default(cuid())
name String @unique
url String
branch String @default("main")
authorization GitHubAppAuthorization @relation(fields: [authorizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
authorizationId String
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
organizationId String
buildCommand String
startCommand String
autoDeploy Boolean @default(true)
envVars Json
status RepositoryProjectStatus @default(PENDING)
statusText String?
currentVMIdentifier String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
deployments ProjectDeployment[] @relation("repoProject")
latestCommit Json?
currentDeployment ProjectDeployment? @relation(fields: [currentDeploymentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
currentDeploymentId String?
workflows Workflow[]
}
enum RepositoryProjectStatus {
PENDING
PREPARING
BUILDING
DEPLOYING
DEPLOYED
ERROR
DISABLED
}
model ProjectDeployment {
id String @id @default(cuid())
project RepositoryProject @relation("repoProject", fields: [projectId], references: [id], onDelete: Cascade, onUpdate: Cascade)
projectId String
environment RuntimeEnvironment @relation(fields: [environmentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
environmentId String
version String
status ProjectDeploymentStatus @default(PENDING)
buildId String @unique
imageId String?
vmIdentifier String?
buildStartedAt DateTime?
buildFinishedAt DateTime?
stoppedAt DateTime?
dockerfile String
dockerIgnore String
branch String
commitHash String
commitMessage String
committer String
error Json?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
projects RepositoryProject[]
logs DeploymentLog[]
polls DeploymentLogPoll[]
@@unique([projectId, version])
}
enum ProjectDeploymentStatus {
PENDING
BUILDING
DEPLOYING
DEPLOYED
CANCELLED
ERROR
STOPPING
STOPPED
}
model DeploymentLog {
id String @id @default(cuid())
deployment ProjectDeployment @relation(fields: [deploymentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
deploymentId String
logType DeploymentLogType @default(BUILD)
logNumber Int @default(0)
log String
level String
createdAt DateTime @default(now())
}
enum DeploymentLogType {
BUILD
MACHINE
}
model DeploymentLogPoll {
id String @id @default(cuid())
deployment ProjectDeployment @relation(fields: [deploymentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
deploymentId String
logType DeploymentLogType @default(BUILD)
from DateTime
to DateTime
totalLogsCount Int
filteredLogsCount Int
nextPollScheduledAt DateTime?
pollNumber Int
createdAt DateTime @default(now())
}
model Template {
id String @id @default(cuid())
slug String @unique
title String
shortTitle String
description String
imageUrl String
repositoryUrl String
markdownDocs String @default("Documentation\n\nThis template does not have any documentation yet.")
runLocalDocs String @default("Documentation\n\nThis template does not have any documentation yet.")
priority Int @default(0)
services String[]
workflowIds String[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
isLive Boolean @default(true)
organizationTemplates OrganizationTemplate[]
}
model OrganizationTemplate {
id String @id @default(cuid())
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
organizationId String
template Template @relation(fields: [templateId], references: [id], onDelete: Cascade, onUpdate: Cascade)
templateId String
authorization GitHubAppAuthorization @relation(fields: [authorizationId], references: [id], onDelete: Cascade, onUpdate: Cascade)
authorizationId String
name String
repositoryId Int @unique
repositoryUrl String
private Boolean
status OrganizationTemplateStatus @default(PENDING)
repositoryData Json
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
workflows Workflow[]
}
enum OrganizationTemplateStatus {
PENDING
CREATED
READY_TO_DEPLOY
DEPLOYED
}
model CurrentEnvironment {
id String @id @default(cuid())
workflow Workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade, onUpdate: Cascade)
workflowId String
environment RuntimeEnvironment @relation(fields: [environmentId], references: [id], onDelete: Cascade, onUpdate: Cascade)
environmentId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
userId String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([workflowId, userId])
}