diff --git a/app/controlplane/pkg/data/ent/migrate/migrations/20260527093110.sql b/app/controlplane/pkg/data/ent/migrate/migrations/20260527093110.sql new file mode 100644 index 000000000..dc5f0b2d8 --- /dev/null +++ b/app/controlplane/pkg/data/ent/migrate/migrations/20260527093110.sql @@ -0,0 +1,2 @@ +-- Modify "workflows" table +ALTER TABLE "workflows" ADD COLUMN "workflow_template_id" uuid NULL; diff --git a/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum b/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum index c0985084b..4eec11dab 100644 --- a/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum +++ b/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:OSH+lqOh2mE49KklM6mUMDQjrL1N2nGHdz9aERNstTM= +h1:q3yyXEwYvGrOTgtEzz+R3LpanOG7wt70Qg/6WiJNHFs= 20230706165452_init-schema.sql h1:VvqbNFEQnCvUVyj2iDYVQQxDM0+sSXqocpt/5H64k8M= 20230710111950-cas-backend.sql h1:A8iBuSzZIEbdsv9ipBtscZQuaBp3V5/VMw7eZH6GX+g= 20230712094107-cas-backends-workflow-runs.sql h1:a5rzxpVGyd56nLRSsKrmCFc9sebg65RWzLghKHh5xvI= @@ -135,3 +135,4 @@ h1:OSH+lqOh2mE49KklM6mUMDQjrL1N2nGHdz9aERNstTM= 20260511202105.sql h1:Tw9OkiWm7cT4p2pNklSUGM9DzKS38uUuYjXl8BdIwnQ= 20260514150303.sql h1:0bGVXYN5rBP9Hn9x/ou8JgKotKiFbSKWGHX2dBH/wCA= 20260516210119.sql h1:rfBnXQwPnrhVYAp/OIiFPGcS+Tx1x9CAMSDPGs8HIT8= +20260527093110.sql h1:Jgq9xDyLakqIVMo3LZF4pPYAkBSc2G5qUK/IV9bzYc4= diff --git a/app/controlplane/pkg/data/ent/migrate/schema.go b/app/controlplane/pkg/data/ent/migrate/schema.go index 4f94ab04c..23354696c 100644 --- a/app/controlplane/pkg/data/ent/migrate/schema.go +++ b/app/controlplane/pkg/data/ent/migrate/schema.go @@ -622,6 +622,7 @@ var ( {Name: "public", Type: field.TypeBool, Default: false}, {Name: "description", Type: field.TypeString, Nullable: true}, {Name: "metadata", Type: field.TypeJSON, Nullable: true}, + {Name: "workflow_template_id", Type: field.TypeUUID, Nullable: true}, {Name: "organization_id", Type: field.TypeUUID}, {Name: "project_id", Type: field.TypeUUID}, {Name: "workflow_contract", Type: field.TypeUUID}, @@ -635,25 +636,25 @@ var ( ForeignKeys: []*schema.ForeignKey{ { Symbol: "workflows_organizations_workflows", - Columns: []*schema.Column{WorkflowsColumns[11]}, + Columns: []*schema.Column{WorkflowsColumns[12]}, RefColumns: []*schema.Column{OrganizationsColumns[0]}, OnDelete: schema.Cascade, }, { Symbol: "workflows_projects_workflows", - Columns: []*schema.Column{WorkflowsColumns[12]}, + Columns: []*schema.Column{WorkflowsColumns[13]}, RefColumns: []*schema.Column{ProjectsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "workflows_workflow_contracts_contract", - Columns: []*schema.Column{WorkflowsColumns[13]}, + Columns: []*schema.Column{WorkflowsColumns[14]}, RefColumns: []*schema.Column{WorkflowContractsColumns[0]}, OnDelete: schema.NoAction, }, { Symbol: "workflows_workflow_runs_latest_workflow_run", - Columns: []*schema.Column{WorkflowsColumns[14]}, + Columns: []*schema.Column{WorkflowsColumns[15]}, RefColumns: []*schema.Column{WorkflowRunsColumns[0]}, OnDelete: schema.SetNull, }, @@ -662,7 +663,7 @@ var ( { Name: "workflow_name_organization_id_project_id", Unique: true, - Columns: []*schema.Column{WorkflowsColumns[1], WorkflowsColumns[11], WorkflowsColumns[12]}, + Columns: []*schema.Column{WorkflowsColumns[1], WorkflowsColumns[12], WorkflowsColumns[13]}, Annotation: &entsql.IndexAnnotation{ Where: "deleted_at IS NULL", }, @@ -670,7 +671,7 @@ var ( { Name: "workflow_organization_id_id", Unique: true, - Columns: []*schema.Column{WorkflowsColumns[11], WorkflowsColumns[0]}, + Columns: []*schema.Column{WorkflowsColumns[12], WorkflowsColumns[0]}, Annotation: &entsql.IndexAnnotation{ Where: "deleted_at IS NULL", }, @@ -678,7 +679,7 @@ var ( { Name: "workflow_organization_id", Unique: false, - Columns: []*schema.Column{WorkflowsColumns[11]}, + Columns: []*schema.Column{WorkflowsColumns[12]}, Annotation: &entsql.IndexAnnotation{ Where: "deleted_at IS NULL", }, @@ -686,7 +687,7 @@ var ( { Name: "workflow_workflow_contract", Unique: false, - Columns: []*schema.Column{WorkflowsColumns[13]}, + Columns: []*schema.Column{WorkflowsColumns[14]}, Annotation: &entsql.IndexAnnotation{ Where: "deleted_at IS NULL", }, diff --git a/app/controlplane/pkg/data/ent/mutation.go b/app/controlplane/pkg/data/ent/mutation.go index 6356b15d1..9fbe5b9d6 100644 --- a/app/controlplane/pkg/data/ent/mutation.go +++ b/app/controlplane/pkg/data/ent/mutation.go @@ -14959,6 +14959,7 @@ type WorkflowMutation struct { public *bool description *string metadata *map[string]interface{} + workflow_template_id *uuid.UUID clearedFields map[string]struct{} robotaccounts map[uuid.UUID]struct{} removedrobotaccounts map[uuid.UUID]struct{} @@ -15655,6 +15656,55 @@ func (m *WorkflowMutation) ResetMetadata() { delete(m.clearedFields, workflow.FieldMetadata) } +// SetWorkflowTemplateID sets the "workflow_template_id" field. +func (m *WorkflowMutation) SetWorkflowTemplateID(u uuid.UUID) { + m.workflow_template_id = &u +} + +// WorkflowTemplateID returns the value of the "workflow_template_id" field in the mutation. +func (m *WorkflowMutation) WorkflowTemplateID() (r uuid.UUID, exists bool) { + v := m.workflow_template_id + if v == nil { + return + } + return *v, true +} + +// OldWorkflowTemplateID returns the old "workflow_template_id" field's value of the Workflow entity. +// If the Workflow object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *WorkflowMutation) OldWorkflowTemplateID(ctx context.Context) (v *uuid.UUID, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldWorkflowTemplateID is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldWorkflowTemplateID requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldWorkflowTemplateID: %w", err) + } + return oldValue.WorkflowTemplateID, nil +} + +// ClearWorkflowTemplateID clears the value of the "workflow_template_id" field. +func (m *WorkflowMutation) ClearWorkflowTemplateID() { + m.workflow_template_id = nil + m.clearedFields[workflow.FieldWorkflowTemplateID] = struct{}{} +} + +// WorkflowTemplateIDCleared returns if the "workflow_template_id" field was cleared in this mutation. +func (m *WorkflowMutation) WorkflowTemplateIDCleared() bool { + _, ok := m.clearedFields[workflow.FieldWorkflowTemplateID] + return ok +} + +// ResetWorkflowTemplateID resets all changes to the "workflow_template_id" field. +func (m *WorkflowMutation) ResetWorkflowTemplateID() { + m.workflow_template_id = nil + delete(m.clearedFields, workflow.FieldWorkflowTemplateID) +} + // AddRobotaccountIDs adds the "robotaccounts" edge to the RobotAccount entity by ids. func (m *WorkflowMutation) AddRobotaccountIDs(ids ...uuid.UUID) { if m.robotaccounts == nil { @@ -16038,7 +16088,7 @@ func (m *WorkflowMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *WorkflowMutation) Fields() []string { - fields := make([]string, 0, 13) + fields := make([]string, 0, 14) if m.name != nil { fields = append(fields, workflow.FieldName) } @@ -16078,6 +16128,9 @@ func (m *WorkflowMutation) Fields() []string { if m.metadata != nil { fields = append(fields, workflow.FieldMetadata) } + if m.workflow_template_id != nil { + fields = append(fields, workflow.FieldWorkflowTemplateID) + } return fields } @@ -16112,6 +16165,8 @@ func (m *WorkflowMutation) Field(name string) (ent.Value, bool) { return m.Description() case workflow.FieldMetadata: return m.Metadata() + case workflow.FieldWorkflowTemplateID: + return m.WorkflowTemplateID() } return nil, false } @@ -16147,6 +16202,8 @@ func (m *WorkflowMutation) OldField(ctx context.Context, name string) (ent.Value return m.OldDescription(ctx) case workflow.FieldMetadata: return m.OldMetadata(ctx) + case workflow.FieldWorkflowTemplateID: + return m.OldWorkflowTemplateID(ctx) } return nil, fmt.Errorf("unknown Workflow field %s", name) } @@ -16247,6 +16304,13 @@ func (m *WorkflowMutation) SetField(name string, value ent.Value) error { } m.SetMetadata(v) return nil + case workflow.FieldWorkflowTemplateID: + v, ok := value.(uuid.UUID) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetWorkflowTemplateID(v) + return nil } return fmt.Errorf("unknown Workflow field %s", name) } @@ -16310,6 +16374,9 @@ func (m *WorkflowMutation) ClearedFields() []string { if m.FieldCleared(workflow.FieldMetadata) { fields = append(fields, workflow.FieldMetadata) } + if m.FieldCleared(workflow.FieldWorkflowTemplateID) { + fields = append(fields, workflow.FieldWorkflowTemplateID) + } return fields } @@ -16342,6 +16409,9 @@ func (m *WorkflowMutation) ClearField(name string) error { case workflow.FieldMetadata: m.ClearMetadata() return nil + case workflow.FieldWorkflowTemplateID: + m.ClearWorkflowTemplateID() + return nil } return fmt.Errorf("unknown Workflow nullable field %s", name) } @@ -16389,6 +16459,9 @@ func (m *WorkflowMutation) ResetField(name string) error { case workflow.FieldMetadata: m.ResetMetadata() return nil + case workflow.FieldWorkflowTemplateID: + m.ResetWorkflowTemplateID() + return nil } return fmt.Errorf("unknown Workflow field %s", name) } diff --git a/app/controlplane/pkg/data/ent/schema/workflow.go b/app/controlplane/pkg/data/ent/schema/workflow.go index c2b91a506..d8146622d 100644 --- a/app/controlplane/pkg/data/ent/schema/workflow.go +++ b/app/controlplane/pkg/data/ent/schema/workflow.go @@ -1,5 +1,5 @@ // -// Copyright 2024 The Chainloop Authors. +// Copyright 2024-2026 The Chainloop Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -59,6 +59,7 @@ func (Workflow) Fields() []ent.Field { field.UUID("latest_run", uuid.UUID{}).Optional().Nillable(), field.String("description").Optional(), field.JSON("metadata", map[string]interface{}{}).Optional(), + field.UUID("workflow_template_id", uuid.UUID{}).Optional().Nillable(), } } diff --git a/app/controlplane/pkg/data/ent/workflow.go b/app/controlplane/pkg/data/ent/workflow.go index 81c7b7517..3192f9dfd 100644 --- a/app/controlplane/pkg/data/ent/workflow.go +++ b/app/controlplane/pkg/data/ent/workflow.go @@ -49,6 +49,8 @@ type Workflow struct { Description string `json:"description,omitempty"` // Metadata holds the value of the "metadata" field. Metadata map[string]interface{} `json:"metadata,omitempty"` + // WorkflowTemplateID holds the value of the "workflow_template_id" field. + WorkflowTemplateID *uuid.UUID `json:"workflow_template_id,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the WorkflowQuery when eager-loading is set. Edges WorkflowEdges `json:"edges"` @@ -164,7 +166,7 @@ func (*Workflow) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case workflow.FieldLatestRun: + case workflow.FieldLatestRun, workflow.FieldWorkflowTemplateID: values[i] = &sql.NullScanner{S: new(uuid.UUID)} case workflow.FieldMetadata: values[i] = new([]byte) @@ -282,6 +284,13 @@ func (_m *Workflow) assignValues(columns []string, values []any) error { return fmt.Errorf("unmarshal field metadata: %w", err) } } + case workflow.FieldWorkflowTemplateID: + if value, ok := values[i].(*sql.NullScanner); !ok { + return fmt.Errorf("unexpected type %T for field workflow_template_id", values[i]) + } else if value.Valid { + _m.WorkflowTemplateID = new(uuid.UUID) + *_m.WorkflowTemplateID = *value.S.(*uuid.UUID) + } case workflow.ForeignKeys[0]: if value, ok := values[i].(*sql.NullScanner); !ok { return fmt.Errorf("unexpected type %T for field workflow_contract", values[i]) @@ -405,6 +414,11 @@ func (_m *Workflow) String() string { builder.WriteString(", ") builder.WriteString("metadata=") builder.WriteString(fmt.Sprintf("%v", _m.Metadata)) + builder.WriteString(", ") + if v := _m.WorkflowTemplateID; v != nil { + builder.WriteString("workflow_template_id=") + builder.WriteString(fmt.Sprintf("%v", *v)) + } builder.WriteByte(')') return builder.String() } diff --git a/app/controlplane/pkg/data/ent/workflow/where.go b/app/controlplane/pkg/data/ent/workflow/where.go index 394e382b4..49869813c 100644 --- a/app/controlplane/pkg/data/ent/workflow/where.go +++ b/app/controlplane/pkg/data/ent/workflow/where.go @@ -116,6 +116,11 @@ func Description(v string) predicate.Workflow { return predicate.Workflow(sql.FieldEQ(FieldDescription, v)) } +// WorkflowTemplateID applies equality check predicate on the "workflow_template_id" field. It's identical to WorkflowTemplateIDEQ. +func WorkflowTemplateID(v uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldEQ(FieldWorkflowTemplateID, v)) +} + // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.Workflow { return predicate.Workflow(sql.FieldEQ(FieldName, v)) @@ -666,6 +671,56 @@ func MetadataNotNil() predicate.Workflow { return predicate.Workflow(sql.FieldNotNull(FieldMetadata)) } +// WorkflowTemplateIDEQ applies the EQ predicate on the "workflow_template_id" field. +func WorkflowTemplateIDEQ(v uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldEQ(FieldWorkflowTemplateID, v)) +} + +// WorkflowTemplateIDNEQ applies the NEQ predicate on the "workflow_template_id" field. +func WorkflowTemplateIDNEQ(v uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldNEQ(FieldWorkflowTemplateID, v)) +} + +// WorkflowTemplateIDIn applies the In predicate on the "workflow_template_id" field. +func WorkflowTemplateIDIn(vs ...uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldIn(FieldWorkflowTemplateID, vs...)) +} + +// WorkflowTemplateIDNotIn applies the NotIn predicate on the "workflow_template_id" field. +func WorkflowTemplateIDNotIn(vs ...uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldNotIn(FieldWorkflowTemplateID, vs...)) +} + +// WorkflowTemplateIDGT applies the GT predicate on the "workflow_template_id" field. +func WorkflowTemplateIDGT(v uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldGT(FieldWorkflowTemplateID, v)) +} + +// WorkflowTemplateIDGTE applies the GTE predicate on the "workflow_template_id" field. +func WorkflowTemplateIDGTE(v uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldGTE(FieldWorkflowTemplateID, v)) +} + +// WorkflowTemplateIDLT applies the LT predicate on the "workflow_template_id" field. +func WorkflowTemplateIDLT(v uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldLT(FieldWorkflowTemplateID, v)) +} + +// WorkflowTemplateIDLTE applies the LTE predicate on the "workflow_template_id" field. +func WorkflowTemplateIDLTE(v uuid.UUID) predicate.Workflow { + return predicate.Workflow(sql.FieldLTE(FieldWorkflowTemplateID, v)) +} + +// WorkflowTemplateIDIsNil applies the IsNil predicate on the "workflow_template_id" field. +func WorkflowTemplateIDIsNil() predicate.Workflow { + return predicate.Workflow(sql.FieldIsNull(FieldWorkflowTemplateID)) +} + +// WorkflowTemplateIDNotNil applies the NotNil predicate on the "workflow_template_id" field. +func WorkflowTemplateIDNotNil() predicate.Workflow { + return predicate.Workflow(sql.FieldNotNull(FieldWorkflowTemplateID)) +} + // HasRobotaccounts applies the HasEdge predicate on the "robotaccounts" edge. func HasRobotaccounts() predicate.Workflow { return predicate.Workflow(func(s *sql.Selector) { diff --git a/app/controlplane/pkg/data/ent/workflow/workflow.go b/app/controlplane/pkg/data/ent/workflow/workflow.go index 671b26c93..db4db10e7 100644 --- a/app/controlplane/pkg/data/ent/workflow/workflow.go +++ b/app/controlplane/pkg/data/ent/workflow/workflow.go @@ -41,6 +41,8 @@ const ( FieldDescription = "description" // FieldMetadata holds the string denoting the metadata field in the database. FieldMetadata = "metadata" + // FieldWorkflowTemplateID holds the string denoting the workflow_template_id field in the database. + FieldWorkflowTemplateID = "workflow_template_id" // EdgeRobotaccounts holds the string denoting the robotaccounts edge name in mutations. EdgeRobotaccounts = "robotaccounts" // EdgeWorkflowruns holds the string denoting the workflowruns edge name in mutations. @@ -131,6 +133,7 @@ var Columns = []string{ FieldLatestRun, FieldDescription, FieldMetadata, + FieldWorkflowTemplateID, } // ForeignKeys holds the SQL foreign-keys that are owned by the "workflows" @@ -241,6 +244,11 @@ func ByDescription(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldDescription, opts...).ToFunc() } +// ByWorkflowTemplateID orders the results by the workflow_template_id field. +func ByWorkflowTemplateID(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldWorkflowTemplateID, opts...).ToFunc() +} + // ByRobotaccountsCount orders the results by robotaccounts count. func ByRobotaccountsCount(opts ...sql.OrderTermOption) OrderOption { return func(s *sql.Selector) { diff --git a/app/controlplane/pkg/data/ent/workflow_create.go b/app/controlplane/pkg/data/ent/workflow_create.go index 68f04b4bd..504d47f14 100644 --- a/app/controlplane/pkg/data/ent/workflow_create.go +++ b/app/controlplane/pkg/data/ent/workflow_create.go @@ -181,6 +181,20 @@ func (_c *WorkflowCreate) SetMetadata(v map[string]interface{}) *WorkflowCreate return _c } +// SetWorkflowTemplateID sets the "workflow_template_id" field. +func (_c *WorkflowCreate) SetWorkflowTemplateID(v uuid.UUID) *WorkflowCreate { + _c.mutation.SetWorkflowTemplateID(v) + return _c +} + +// SetNillableWorkflowTemplateID sets the "workflow_template_id" field if the given value is not nil. +func (_c *WorkflowCreate) SetNillableWorkflowTemplateID(v *uuid.UUID) *WorkflowCreate { + if v != nil { + _c.SetWorkflowTemplateID(*v) + } + return _c +} + // SetID sets the "id" field. func (_c *WorkflowCreate) SetID(v uuid.UUID) *WorkflowCreate { _c.mutation.SetID(v) @@ -460,6 +474,10 @@ func (_c *WorkflowCreate) createSpec() (*Workflow, *sqlgraph.CreateSpec) { _spec.SetField(workflow.FieldMetadata, field.TypeJSON, value) _node.Metadata = value } + if value, ok := _c.mutation.WorkflowTemplateID(); ok { + _spec.SetField(workflow.FieldWorkflowTemplateID, field.TypeUUID, value) + _node.WorkflowTemplateID = &value + } if nodes := _c.mutation.RobotaccountsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -818,6 +836,24 @@ func (u *WorkflowUpsert) ClearMetadata() *WorkflowUpsert { return u } +// SetWorkflowTemplateID sets the "workflow_template_id" field. +func (u *WorkflowUpsert) SetWorkflowTemplateID(v uuid.UUID) *WorkflowUpsert { + u.Set(workflow.FieldWorkflowTemplateID, v) + return u +} + +// UpdateWorkflowTemplateID sets the "workflow_template_id" field to the value that was provided on create. +func (u *WorkflowUpsert) UpdateWorkflowTemplateID() *WorkflowUpsert { + u.SetExcluded(workflow.FieldWorkflowTemplateID) + return u +} + +// ClearWorkflowTemplateID clears the value of the "workflow_template_id" field. +func (u *WorkflowUpsert) ClearWorkflowTemplateID() *WorkflowUpsert { + u.SetNull(workflow.FieldWorkflowTemplateID) + return u +} + // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // @@ -1075,6 +1111,27 @@ func (u *WorkflowUpsertOne) ClearMetadata() *WorkflowUpsertOne { }) } +// SetWorkflowTemplateID sets the "workflow_template_id" field. +func (u *WorkflowUpsertOne) SetWorkflowTemplateID(v uuid.UUID) *WorkflowUpsertOne { + return u.Update(func(s *WorkflowUpsert) { + s.SetWorkflowTemplateID(v) + }) +} + +// UpdateWorkflowTemplateID sets the "workflow_template_id" field to the value that was provided on create. +func (u *WorkflowUpsertOne) UpdateWorkflowTemplateID() *WorkflowUpsertOne { + return u.Update(func(s *WorkflowUpsert) { + s.UpdateWorkflowTemplateID() + }) +} + +// ClearWorkflowTemplateID clears the value of the "workflow_template_id" field. +func (u *WorkflowUpsertOne) ClearWorkflowTemplateID() *WorkflowUpsertOne { + return u.Update(func(s *WorkflowUpsert) { + s.ClearWorkflowTemplateID() + }) +} + // Exec executes the query. func (u *WorkflowUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { @@ -1499,6 +1556,27 @@ func (u *WorkflowUpsertBulk) ClearMetadata() *WorkflowUpsertBulk { }) } +// SetWorkflowTemplateID sets the "workflow_template_id" field. +func (u *WorkflowUpsertBulk) SetWorkflowTemplateID(v uuid.UUID) *WorkflowUpsertBulk { + return u.Update(func(s *WorkflowUpsert) { + s.SetWorkflowTemplateID(v) + }) +} + +// UpdateWorkflowTemplateID sets the "workflow_template_id" field to the value that was provided on create. +func (u *WorkflowUpsertBulk) UpdateWorkflowTemplateID() *WorkflowUpsertBulk { + return u.Update(func(s *WorkflowUpsert) { + s.UpdateWorkflowTemplateID() + }) +} + +// ClearWorkflowTemplateID clears the value of the "workflow_template_id" field. +func (u *WorkflowUpsertBulk) ClearWorkflowTemplateID() *WorkflowUpsertBulk { + return u.Update(func(s *WorkflowUpsert) { + s.ClearWorkflowTemplateID() + }) +} + // Exec executes the query. func (u *WorkflowUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { diff --git a/app/controlplane/pkg/data/ent/workflow_update.go b/app/controlplane/pkg/data/ent/workflow_update.go index 01f5b2291..0c36e2a8f 100644 --- a/app/controlplane/pkg/data/ent/workflow_update.go +++ b/app/controlplane/pkg/data/ent/workflow_update.go @@ -226,6 +226,26 @@ func (_u *WorkflowUpdate) ClearMetadata() *WorkflowUpdate { return _u } +// SetWorkflowTemplateID sets the "workflow_template_id" field. +func (_u *WorkflowUpdate) SetWorkflowTemplateID(v uuid.UUID) *WorkflowUpdate { + _u.mutation.SetWorkflowTemplateID(v) + return _u +} + +// SetNillableWorkflowTemplateID sets the "workflow_template_id" field if the given value is not nil. +func (_u *WorkflowUpdate) SetNillableWorkflowTemplateID(v *uuid.UUID) *WorkflowUpdate { + if v != nil { + _u.SetWorkflowTemplateID(*v) + } + return _u +} + +// ClearWorkflowTemplateID clears the value of the "workflow_template_id" field. +func (_u *WorkflowUpdate) ClearWorkflowTemplateID() *WorkflowUpdate { + _u.mutation.ClearWorkflowTemplateID() + return _u +} + // AddRobotaccountIDs adds the "robotaccounts" edge to the RobotAccount entity by IDs. func (_u *WorkflowUpdate) AddRobotaccountIDs(ids ...uuid.UUID) *WorkflowUpdate { _u.mutation.AddRobotaccountIDs(ids...) @@ -540,6 +560,12 @@ func (_u *WorkflowUpdate) sqlSave(ctx context.Context) (_node int, err error) { if _u.mutation.MetadataCleared() { _spec.ClearField(workflow.FieldMetadata, field.TypeJSON) } + if value, ok := _u.mutation.WorkflowTemplateID(); ok { + _spec.SetField(workflow.FieldWorkflowTemplateID, field.TypeUUID, value) + } + if _u.mutation.WorkflowTemplateIDCleared() { + _spec.ClearField(workflow.FieldWorkflowTemplateID, field.TypeUUID) + } if _u.mutation.RobotaccountsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, @@ -1047,6 +1073,26 @@ func (_u *WorkflowUpdateOne) ClearMetadata() *WorkflowUpdateOne { return _u } +// SetWorkflowTemplateID sets the "workflow_template_id" field. +func (_u *WorkflowUpdateOne) SetWorkflowTemplateID(v uuid.UUID) *WorkflowUpdateOne { + _u.mutation.SetWorkflowTemplateID(v) + return _u +} + +// SetNillableWorkflowTemplateID sets the "workflow_template_id" field if the given value is not nil. +func (_u *WorkflowUpdateOne) SetNillableWorkflowTemplateID(v *uuid.UUID) *WorkflowUpdateOne { + if v != nil { + _u.SetWorkflowTemplateID(*v) + } + return _u +} + +// ClearWorkflowTemplateID clears the value of the "workflow_template_id" field. +func (_u *WorkflowUpdateOne) ClearWorkflowTemplateID() *WorkflowUpdateOne { + _u.mutation.ClearWorkflowTemplateID() + return _u +} + // AddRobotaccountIDs adds the "robotaccounts" edge to the RobotAccount entity by IDs. func (_u *WorkflowUpdateOne) AddRobotaccountIDs(ids ...uuid.UUID) *WorkflowUpdateOne { _u.mutation.AddRobotaccountIDs(ids...) @@ -1391,6 +1437,12 @@ func (_u *WorkflowUpdateOne) sqlSave(ctx context.Context) (_node *Workflow, err if _u.mutation.MetadataCleared() { _spec.ClearField(workflow.FieldMetadata, field.TypeJSON) } + if value, ok := _u.mutation.WorkflowTemplateID(); ok { + _spec.SetField(workflow.FieldWorkflowTemplateID, field.TypeUUID, value) + } + if _u.mutation.WorkflowTemplateIDCleared() { + _spec.ClearField(workflow.FieldWorkflowTemplateID, field.TypeUUID) + } if _u.mutation.RobotaccountsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M,