Files
HiveGrid-Wireframes/hivegrid-cloud/prisma/schema/workflows.prisma
T

152 lines
6.5 KiB
Plaintext

model Workflow {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
name String
description String
status String @default("draft")
tenantId String?
tenant Tenant? @relation(fields: [tenantId], references: [id])
createdByUserId String?
createdByUser User? @relation(name: "createdByUser", fields: [createdByUserId], references: [id])
appliesToAllTenants Boolean @default(false)
blocks WorkflowBlock[]
inputExamples WorkflowInputExample[]
executions WorkflowExecution[]
}
model WorkflowBlock {
id String @id @default(cuid())
workflowId String // Foreign key to the Workflow
workflow Workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
type String
description String
isTrigger Boolean @default(false)
isBlock Boolean @default(false)
fromBlocks WorkflowBlockToBlock[] @relation(name: "toBlock")
toBlocks WorkflowBlockToBlock[] @relation(name: "fromBlock")
input String
executions WorkflowBlockExecution[] @relation(name: "executions")
fromExecutions WorkflowBlockExecution[] @relation(name: "fromExecutions")
conditionsGroups WorkflowBlockConditionGroup[]
waitingInExecutions WorkflowExecution[]
}
model WorkflowBlockConditionGroup {
id String @id @default(cuid())
workflowBlockId String
workflowBlock WorkflowBlock @relation(fields: [workflowBlockId], references: [id], onDelete: Cascade)
index Int
type String // AND or OR
conditions WorkflowBlockCondition[]
}
model WorkflowBlockCondition {
id String @id @default(cuid())
workflowBlockConditionGroupId String
workflowBlockConditionGroup WorkflowBlockConditionGroup @relation(fields: [workflowBlockConditionGroupId], references: [id], onDelete: Cascade)
index Int
variable String
operator String
value String
}
model WorkflowBlockToBlock {
id String @id @default(cuid())
fromBlockId String
fromBlock WorkflowBlock @relation(name: "fromBlock", fields: [fromBlockId], references: [id], onDelete: Cascade)
toBlockId String
toBlock WorkflowBlock @relation(name: "toBlock", fields: [toBlockId], references: [id], onDelete: Cascade)
condition String?
@@unique([fromBlockId, toBlockId])
}
model WorkflowExecution {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
workflowId String
workflow Workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade)
tenantId String?
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
type String // manual, api, stream
status String
input String
output String?
duration Int?
endedAt DateTime?
error String?
waitingBlockId String?
waitingBlock WorkflowBlock? @relation(fields: [waitingBlockId], references: [id])
createdByUserId String?
createdByUser User? @relation(name: "executedByUser", fields: [createdByUserId], references: [id])
appliesToAllTenants Boolean @default(false)
blockRuns WorkflowBlockExecution[]
@@index([tenantId, appliesToAllTenants, createdAt(sort: Desc)], name: "workflow_execution_tenant_scope_created_at_idx")
@@index([workflowId, tenantId, createdAt(sort: Desc)], name: "workflow_execution_workflow_tenant_created_at_idx")
@@index([tenantId, status, createdAt(sort: Desc)], name: "workflow_execution_tenant_status_created_at_idx")
@@index([tenantId, type, createdAt(sort: Desc)], name: "workflow_execution_tenant_type_created_at_idx")
}
model WorkflowInputExample {
id String @id @default(cuid())
createdAt DateTime @default(now())
workflowId String
workflow Workflow @relation(fields: [workflowId], references: [id], onDelete: Cascade)
title String
input String?
@@unique([workflowId, title])
}
model WorkflowBlockExecution {
id String @id @default(cuid())
workflowExecutionId String
workflowExecution WorkflowExecution @relation(fields: [workflowExecutionId], references: [id], onDelete: Cascade)
workflowBlockId String
workflowBlock WorkflowBlock @relation(name: "executions", fields: [workflowBlockId], references: [id], onDelete: Cascade)
fromWorkflowBlockId String?
fromWorkflowBlock WorkflowBlock? @relation(name: "fromExecutions", fields: [fromWorkflowBlockId], references: [id])
status String
startedAt DateTime
input String?
output String?
duration Int?
endedAt DateTime?
error String?
}
model WorkflowVariable {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
tenantId String?
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
name String
value String
createdByUserId String?
createdByUser User? @relation(fields: [userId], references: [id])
userId String?
@@unique([tenantId, name])
}
model WorkflowCredential {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
tenantId String?
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: Cascade)
name String
value String
createdByUserId String?
createdByUser User? @relation(fields: [userId], references: [id])
userId String?
@@unique([tenantId, name])
}