Skip to content

Commit

Permalink
feat: playbook run parent
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Jan 9, 2025
1 parent 0c9e529 commit 90be3f8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions models/playbooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func (p Playbook) PK() string {
return p.ID.String()
}

var PlaybookRunStatusFinalStates = []PlaybookRunStatus{
PlaybookRunStatusCancelled,
PlaybookRunStatusCompleted,
PlaybookRunStatusFailed,
}

var PlaybookRunStatusExecutingGroup = []PlaybookRunStatus{
PlaybookRunStatusRunning,
PlaybookRunStatusScheduled,
Expand Down Expand Up @@ -186,6 +192,10 @@ type PlaybookRun struct {
Request types.JSONMap `json:"request,omitempty" gorm:"default:null"`
AgentID *uuid.UUID `json:"agent_id,omitempty"`

// Parent Run's id
ParentID *uuid.UUID `json:"parent_id,omitempty"`

// Parent notification send's id
NotificationSendID *uuid.UUID `json:"notification_send_id,omitempty"`
}

Expand Down
14 changes: 14 additions & 0 deletions schema/playbooks.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,24 @@ table "playbook_runs" {
default = var.uuid_nil
type = uuid
}
column "parent_id" {
null = true
type = uuid
comment = "references the run that triggered this run"
}
column "error" {
null = true
type = text
}
primary_key {
columns = [column.id]
}
foreign_key "playbook_run_parent_id_fkey" {
columns = [column.parent_id]
ref_columns = [table.playbook_runs.column.id]
on_update = NO_ACTION
on_delete = NO_ACTION
}
foreign_key "playbook_run_playbook_id_fkey" {
columns = [column.playbook_id]
ref_columns = [table.playbooks.column.id]
Expand Down Expand Up @@ -252,6 +263,9 @@ table "playbook_runs" {
on_update = NO_ACTION
on_delete = NO_ACTION
}
index "idx_playbook_runs_parent_id" {
columns = [column.parent_id]
}
}

table "playbook_action_agent_data" {
Expand Down

0 comments on commit 90be3f8

Please sign in to comment.