diff --git a/internal-packages/database/prisma/schema.prisma b/internal-packages/database/prisma/schema.prisma index c83bf6947..d9e177c6f 100644 --- a/internal-packages/database/prisma/schema.prisma +++ b/internal-packages/database/prisma/schema.prisma @@ -50,6 +50,7 @@ model User { invitationCodeId String? personalAccessTokens PersonalAccessToken[] deployments WorkerDeployment[] + bulkActions BulkActionGroup[] } // @deprecated This model is no longer used as the Cloud is out of private beta @@ -266,6 +267,7 @@ model RuntimeEnvironment { workerInstances WorkerInstance[] executionSnapshots TaskRunExecutionSnapshot[] waitpointTags WaitpointTag[] + BulkActionGroup BulkActionGroup[] @@unique([projectId, slug, orgMemberId]) @@unique([projectId, shortcode]) @@ -1915,14 +1917,37 @@ model BulkActionGroup { project Project @relation(fields: [projectId], references: [id], onDelete: Cascade, onUpdate: Cascade) projectId String + /// If this is set then it's a V2 Bulk Action that supports queries + environment RuntimeEnvironment? @relation(fields: [environmentId], references: [id], onDelete: Cascade, onUpdate: Cascade) + environmentId String? + type BulkActionType items BulkActionItem[] /// When the group is created it's pending. After we've processed all the items it's completed. This does not mean the associated runs are completed. status BulkActionStatus @default(PENDING) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + /// The query that will be executed to get the runs to process (if null, we are passing run ids directly) + queryName String? + /// The params that will be passed to the query + params Json? + /// The cursor that will be passed to the query (null for the first page) + cursor Json? + /// The number of runs that have been processed + processedCount Int @default(0) + /// The total number of runs that will be processed + totalCount Int @default(0) + + /// The userId who did the bulk action + user User? @relation(fields: [userId], references: [id], onDelete: SetNull, onUpdate: Cascade) + userId String? + + /// Why the user did the bulk action + reason String? + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + runtimeEnvironmentId String } enum BulkActionType { @@ -1940,7 +1965,7 @@ enum BulkActionStatus { model BulkActionItem { id String @id @default(cuid()) - friendlyId String @unique + friendlyId String? group BulkActionGroup @relation(fields: [groupId], references: [id], onDelete: Cascade, onUpdate: Cascade) groupId String