// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"registry-backend/ent/ciworkflowresult"
	"registry-backend/ent/gitcommit"
	"registry-backend/ent/schema"
	"registry-backend/ent/storagefile"
	"time"

	"entgo.io/ent/dialect"
	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/google/uuid"
)

// CIWorkflowResultCreate is the builder for creating a CIWorkflowResult entity.
type CIWorkflowResultCreate struct {
	config
	mutation *CIWorkflowResultMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetCreateTime sets the "create_time" field.
func (cwrc *CIWorkflowResultCreate) SetCreateTime(t time.Time) *CIWorkflowResultCreate {
	cwrc.mutation.SetCreateTime(t)
	return cwrc
}

// SetNillableCreateTime sets the "create_time" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableCreateTime(t *time.Time) *CIWorkflowResultCreate {
	if t != nil {
		cwrc.SetCreateTime(*t)
	}
	return cwrc
}

// SetUpdateTime sets the "update_time" field.
func (cwrc *CIWorkflowResultCreate) SetUpdateTime(t time.Time) *CIWorkflowResultCreate {
	cwrc.mutation.SetUpdateTime(t)
	return cwrc
}

// SetNillableUpdateTime sets the "update_time" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableUpdateTime(t *time.Time) *CIWorkflowResultCreate {
	if t != nil {
		cwrc.SetUpdateTime(*t)
	}
	return cwrc
}

// SetOperatingSystem sets the "operating_system" field.
func (cwrc *CIWorkflowResultCreate) SetOperatingSystem(s string) *CIWorkflowResultCreate {
	cwrc.mutation.SetOperatingSystem(s)
	return cwrc
}

// SetWorkflowName sets the "workflow_name" field.
func (cwrc *CIWorkflowResultCreate) SetWorkflowName(s string) *CIWorkflowResultCreate {
	cwrc.mutation.SetWorkflowName(s)
	return cwrc
}

// SetNillableWorkflowName sets the "workflow_name" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableWorkflowName(s *string) *CIWorkflowResultCreate {
	if s != nil {
		cwrc.SetWorkflowName(*s)
	}
	return cwrc
}

// SetRunID sets the "run_id" field.
func (cwrc *CIWorkflowResultCreate) SetRunID(s string) *CIWorkflowResultCreate {
	cwrc.mutation.SetRunID(s)
	return cwrc
}

// SetNillableRunID sets the "run_id" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableRunID(s *string) *CIWorkflowResultCreate {
	if s != nil {
		cwrc.SetRunID(*s)
	}
	return cwrc
}

// SetJobID sets the "job_id" field.
func (cwrc *CIWorkflowResultCreate) SetJobID(s string) *CIWorkflowResultCreate {
	cwrc.mutation.SetJobID(s)
	return cwrc
}

// SetNillableJobID sets the "job_id" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableJobID(s *string) *CIWorkflowResultCreate {
	if s != nil {
		cwrc.SetJobID(*s)
	}
	return cwrc
}

// SetStatus sets the "status" field.
func (cwrc *CIWorkflowResultCreate) SetStatus(srst schema.WorkflowRunStatusType) *CIWorkflowResultCreate {
	cwrc.mutation.SetStatus(srst)
	return cwrc
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableStatus(srst *schema.WorkflowRunStatusType) *CIWorkflowResultCreate {
	if srst != nil {
		cwrc.SetStatus(*srst)
	}
	return cwrc
}

// SetStartTime sets the "start_time" field.
func (cwrc *CIWorkflowResultCreate) SetStartTime(i int64) *CIWorkflowResultCreate {
	cwrc.mutation.SetStartTime(i)
	return cwrc
}

// SetNillableStartTime sets the "start_time" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableStartTime(i *int64) *CIWorkflowResultCreate {
	if i != nil {
		cwrc.SetStartTime(*i)
	}
	return cwrc
}

// SetEndTime sets the "end_time" field.
func (cwrc *CIWorkflowResultCreate) SetEndTime(i int64) *CIWorkflowResultCreate {
	cwrc.mutation.SetEndTime(i)
	return cwrc
}

// SetNillableEndTime sets the "end_time" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableEndTime(i *int64) *CIWorkflowResultCreate {
	if i != nil {
		cwrc.SetEndTime(*i)
	}
	return cwrc
}

// SetPythonVersion sets the "python_version" field.
func (cwrc *CIWorkflowResultCreate) SetPythonVersion(s string) *CIWorkflowResultCreate {
	cwrc.mutation.SetPythonVersion(s)
	return cwrc
}

// SetNillablePythonVersion sets the "python_version" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillablePythonVersion(s *string) *CIWorkflowResultCreate {
	if s != nil {
		cwrc.SetPythonVersion(*s)
	}
	return cwrc
}

// SetPytorchVersion sets the "pytorch_version" field.
func (cwrc *CIWorkflowResultCreate) SetPytorchVersion(s string) *CIWorkflowResultCreate {
	cwrc.mutation.SetPytorchVersion(s)
	return cwrc
}

// SetNillablePytorchVersion sets the "pytorch_version" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillablePytorchVersion(s *string) *CIWorkflowResultCreate {
	if s != nil {
		cwrc.SetPytorchVersion(*s)
	}
	return cwrc
}

// SetCudaVersion sets the "cuda_version" field.
func (cwrc *CIWorkflowResultCreate) SetCudaVersion(s string) *CIWorkflowResultCreate {
	cwrc.mutation.SetCudaVersion(s)
	return cwrc
}

// SetNillableCudaVersion sets the "cuda_version" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableCudaVersion(s *string) *CIWorkflowResultCreate {
	if s != nil {
		cwrc.SetCudaVersion(*s)
	}
	return cwrc
}

// SetComfyRunFlags sets the "comfy_run_flags" field.
func (cwrc *CIWorkflowResultCreate) SetComfyRunFlags(s string) *CIWorkflowResultCreate {
	cwrc.mutation.SetComfyRunFlags(s)
	return cwrc
}

// SetNillableComfyRunFlags sets the "comfy_run_flags" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableComfyRunFlags(s *string) *CIWorkflowResultCreate {
	if s != nil {
		cwrc.SetComfyRunFlags(*s)
	}
	return cwrc
}

// SetAvgVram sets the "avg_vram" field.
func (cwrc *CIWorkflowResultCreate) SetAvgVram(i int) *CIWorkflowResultCreate {
	cwrc.mutation.SetAvgVram(i)
	return cwrc
}

// SetNillableAvgVram sets the "avg_vram" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableAvgVram(i *int) *CIWorkflowResultCreate {
	if i != nil {
		cwrc.SetAvgVram(*i)
	}
	return cwrc
}

// SetPeakVram sets the "peak_vram" field.
func (cwrc *CIWorkflowResultCreate) SetPeakVram(i int) *CIWorkflowResultCreate {
	cwrc.mutation.SetPeakVram(i)
	return cwrc
}

// SetNillablePeakVram sets the "peak_vram" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillablePeakVram(i *int) *CIWorkflowResultCreate {
	if i != nil {
		cwrc.SetPeakVram(*i)
	}
	return cwrc
}

// SetJobTriggerUser sets the "job_trigger_user" field.
func (cwrc *CIWorkflowResultCreate) SetJobTriggerUser(s string) *CIWorkflowResultCreate {
	cwrc.mutation.SetJobTriggerUser(s)
	return cwrc
}

// SetNillableJobTriggerUser sets the "job_trigger_user" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableJobTriggerUser(s *string) *CIWorkflowResultCreate {
	if s != nil {
		cwrc.SetJobTriggerUser(*s)
	}
	return cwrc
}

// SetMetadata sets the "metadata" field.
func (cwrc *CIWorkflowResultCreate) SetMetadata(m map[string]interface{}) *CIWorkflowResultCreate {
	cwrc.mutation.SetMetadata(m)
	return cwrc
}

// SetID sets the "id" field.
func (cwrc *CIWorkflowResultCreate) SetID(u uuid.UUID) *CIWorkflowResultCreate {
	cwrc.mutation.SetID(u)
	return cwrc
}

// SetNillableID sets the "id" field if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableID(u *uuid.UUID) *CIWorkflowResultCreate {
	if u != nil {
		cwrc.SetID(*u)
	}
	return cwrc
}

// SetGitcommitID sets the "gitcommit" edge to the GitCommit entity by ID.
func (cwrc *CIWorkflowResultCreate) SetGitcommitID(id uuid.UUID) *CIWorkflowResultCreate {
	cwrc.mutation.SetGitcommitID(id)
	return cwrc
}

// SetNillableGitcommitID sets the "gitcommit" edge to the GitCommit entity by ID if the given value is not nil.
func (cwrc *CIWorkflowResultCreate) SetNillableGitcommitID(id *uuid.UUID) *CIWorkflowResultCreate {
	if id != nil {
		cwrc = cwrc.SetGitcommitID(*id)
	}
	return cwrc
}

// SetGitcommit sets the "gitcommit" edge to the GitCommit entity.
func (cwrc *CIWorkflowResultCreate) SetGitcommit(g *GitCommit) *CIWorkflowResultCreate {
	return cwrc.SetGitcommitID(g.ID)
}

// AddStorageFileIDs adds the "storage_file" edge to the StorageFile entity by IDs.
func (cwrc *CIWorkflowResultCreate) AddStorageFileIDs(ids ...uuid.UUID) *CIWorkflowResultCreate {
	cwrc.mutation.AddStorageFileIDs(ids...)
	return cwrc
}

// AddStorageFile adds the "storage_file" edges to the StorageFile entity.
func (cwrc *CIWorkflowResultCreate) AddStorageFile(s ...*StorageFile) *CIWorkflowResultCreate {
	ids := make([]uuid.UUID, len(s))
	for i := range s {
		ids[i] = s[i].ID
	}
	return cwrc.AddStorageFileIDs(ids...)
}

// Mutation returns the CIWorkflowResultMutation object of the builder.
func (cwrc *CIWorkflowResultCreate) Mutation() *CIWorkflowResultMutation {
	return cwrc.mutation
}

// Save creates the CIWorkflowResult in the database.
func (cwrc *CIWorkflowResultCreate) Save(ctx context.Context) (*CIWorkflowResult, error) {
	cwrc.defaults()
	return withHooks(ctx, cwrc.sqlSave, cwrc.mutation, cwrc.hooks)
}

// SaveX calls Save and panics if Save returns an error.
func (cwrc *CIWorkflowResultCreate) SaveX(ctx context.Context) *CIWorkflowResult {
	v, err := cwrc.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (cwrc *CIWorkflowResultCreate) Exec(ctx context.Context) error {
	_, err := cwrc.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (cwrc *CIWorkflowResultCreate) ExecX(ctx context.Context) {
	if err := cwrc.Exec(ctx); err != nil {
		panic(err)
	}
}

// defaults sets the default values of the builder before save.
func (cwrc *CIWorkflowResultCreate) defaults() {
	if _, ok := cwrc.mutation.CreateTime(); !ok {
		v := ciworkflowresult.DefaultCreateTime()
		cwrc.mutation.SetCreateTime(v)
	}
	if _, ok := cwrc.mutation.UpdateTime(); !ok {
		v := ciworkflowresult.DefaultUpdateTime()
		cwrc.mutation.SetUpdateTime(v)
	}
	if _, ok := cwrc.mutation.Status(); !ok {
		v := ciworkflowresult.DefaultStatus
		cwrc.mutation.SetStatus(v)
	}
	if _, ok := cwrc.mutation.ID(); !ok {
		v := ciworkflowresult.DefaultID()
		cwrc.mutation.SetID(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (cwrc *CIWorkflowResultCreate) check() error {
	if _, ok := cwrc.mutation.CreateTime(); !ok {
		return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "CIWorkflowResult.create_time"`)}
	}
	if _, ok := cwrc.mutation.UpdateTime(); !ok {
		return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "CIWorkflowResult.update_time"`)}
	}
	if _, ok := cwrc.mutation.OperatingSystem(); !ok {
		return &ValidationError{Name: "operating_system", err: errors.New(`ent: missing required field "CIWorkflowResult.operating_system"`)}
	}
	if _, ok := cwrc.mutation.Status(); !ok {
		return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "CIWorkflowResult.status"`)}
	}
	return nil
}

func (cwrc *CIWorkflowResultCreate) sqlSave(ctx context.Context) (*CIWorkflowResult, error) {
	if err := cwrc.check(); err != nil {
		return nil, err
	}
	_node, _spec := cwrc.createSpec()
	if err := sqlgraph.CreateNode(ctx, cwrc.driver, _spec); err != nil {
		if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	if _spec.ID.Value != nil {
		if id, ok := _spec.ID.Value.(*uuid.UUID); ok {
			_node.ID = *id
		} else if err := _node.ID.Scan(_spec.ID.Value); err != nil {
			return nil, err
		}
	}
	cwrc.mutation.id = &_node.ID
	cwrc.mutation.done = true
	return _node, nil
}

func (cwrc *CIWorkflowResultCreate) createSpec() (*CIWorkflowResult, *sqlgraph.CreateSpec) {
	var (
		_node = &CIWorkflowResult{config: cwrc.config}
		_spec = sqlgraph.NewCreateSpec(ciworkflowresult.Table, sqlgraph.NewFieldSpec(ciworkflowresult.FieldID, field.TypeUUID))
	)
	_spec.OnConflict = cwrc.conflict
	if id, ok := cwrc.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = &id
	}
	if value, ok := cwrc.mutation.CreateTime(); ok {
		_spec.SetField(ciworkflowresult.FieldCreateTime, field.TypeTime, value)
		_node.CreateTime = value
	}
	if value, ok := cwrc.mutation.UpdateTime(); ok {
		_spec.SetField(ciworkflowresult.FieldUpdateTime, field.TypeTime, value)
		_node.UpdateTime = value
	}
	if value, ok := cwrc.mutation.OperatingSystem(); ok {
		_spec.SetField(ciworkflowresult.FieldOperatingSystem, field.TypeString, value)
		_node.OperatingSystem = value
	}
	if value, ok := cwrc.mutation.WorkflowName(); ok {
		_spec.SetField(ciworkflowresult.FieldWorkflowName, field.TypeString, value)
		_node.WorkflowName = value
	}
	if value, ok := cwrc.mutation.RunID(); ok {
		_spec.SetField(ciworkflowresult.FieldRunID, field.TypeString, value)
		_node.RunID = value
	}
	if value, ok := cwrc.mutation.JobID(); ok {
		_spec.SetField(ciworkflowresult.FieldJobID, field.TypeString, value)
		_node.JobID = value
	}
	if value, ok := cwrc.mutation.Status(); ok {
		_spec.SetField(ciworkflowresult.FieldStatus, field.TypeString, value)
		_node.Status = value
	}
	if value, ok := cwrc.mutation.StartTime(); ok {
		_spec.SetField(ciworkflowresult.FieldStartTime, field.TypeInt64, value)
		_node.StartTime = value
	}
	if value, ok := cwrc.mutation.EndTime(); ok {
		_spec.SetField(ciworkflowresult.FieldEndTime, field.TypeInt64, value)
		_node.EndTime = value
	}
	if value, ok := cwrc.mutation.PythonVersion(); ok {
		_spec.SetField(ciworkflowresult.FieldPythonVersion, field.TypeString, value)
		_node.PythonVersion = value
	}
	if value, ok := cwrc.mutation.PytorchVersion(); ok {
		_spec.SetField(ciworkflowresult.FieldPytorchVersion, field.TypeString, value)
		_node.PytorchVersion = value
	}
	if value, ok := cwrc.mutation.CudaVersion(); ok {
		_spec.SetField(ciworkflowresult.FieldCudaVersion, field.TypeString, value)
		_node.CudaVersion = value
	}
	if value, ok := cwrc.mutation.ComfyRunFlags(); ok {
		_spec.SetField(ciworkflowresult.FieldComfyRunFlags, field.TypeString, value)
		_node.ComfyRunFlags = value
	}
	if value, ok := cwrc.mutation.AvgVram(); ok {
		_spec.SetField(ciworkflowresult.FieldAvgVram, field.TypeInt, value)
		_node.AvgVram = value
	}
	if value, ok := cwrc.mutation.PeakVram(); ok {
		_spec.SetField(ciworkflowresult.FieldPeakVram, field.TypeInt, value)
		_node.PeakVram = value
	}
	if value, ok := cwrc.mutation.JobTriggerUser(); ok {
		_spec.SetField(ciworkflowresult.FieldJobTriggerUser, field.TypeString, value)
		_node.JobTriggerUser = value
	}
	if value, ok := cwrc.mutation.Metadata(); ok {
		_spec.SetField(ciworkflowresult.FieldMetadata, field.TypeJSON, value)
		_node.Metadata = value
	}
	if nodes := cwrc.mutation.GitcommitIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   ciworkflowresult.GitcommitTable,
			Columns: []string{ciworkflowresult.GitcommitColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(gitcommit.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.git_commit_results = &nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := cwrc.mutation.StorageFileIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   ciworkflowresult.StorageFileTable,
			Columns: []string{ciworkflowresult.StorageFileColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(storagefile.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	return _node, _spec
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.CIWorkflowResult.Create().
//		SetCreateTime(v).
//		OnConflict(
//			// Update the row with the new values
//			// the was proposed for insertion.
//			sql.ResolveWithNewValues(),
//		).
//		// Override some of the fields with custom
//		// update values.
//		Update(func(u *ent.CIWorkflowResultUpsert) {
//			SetCreateTime(v+v).
//		}).
//		Exec(ctx)
func (cwrc *CIWorkflowResultCreate) OnConflict(opts ...sql.ConflictOption) *CIWorkflowResultUpsertOne {
	cwrc.conflict = opts
	return &CIWorkflowResultUpsertOne{
		create: cwrc,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.CIWorkflowResult.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (cwrc *CIWorkflowResultCreate) OnConflictColumns(columns ...string) *CIWorkflowResultUpsertOne {
	cwrc.conflict = append(cwrc.conflict, sql.ConflictColumns(columns...))
	return &CIWorkflowResultUpsertOne{
		create: cwrc,
	}
}

type (
	// CIWorkflowResultUpsertOne is the builder for "upsert"-ing
	//  one CIWorkflowResult node.
	CIWorkflowResultUpsertOne struct {
		create *CIWorkflowResultCreate
	}

	// CIWorkflowResultUpsert is the "OnConflict" setter.
	CIWorkflowResultUpsert struct {
		*sql.UpdateSet
	}
)

// SetUpdateTime sets the "update_time" field.
func (u *CIWorkflowResultUpsert) SetUpdateTime(v time.Time) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldUpdateTime, v)
	return u
}

// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateUpdateTime() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldUpdateTime)
	return u
}

// SetOperatingSystem sets the "operating_system" field.
func (u *CIWorkflowResultUpsert) SetOperatingSystem(v string) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldOperatingSystem, v)
	return u
}

// UpdateOperatingSystem sets the "operating_system" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateOperatingSystem() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldOperatingSystem)
	return u
}

// SetWorkflowName sets the "workflow_name" field.
func (u *CIWorkflowResultUpsert) SetWorkflowName(v string) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldWorkflowName, v)
	return u
}

// UpdateWorkflowName sets the "workflow_name" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateWorkflowName() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldWorkflowName)
	return u
}

// ClearWorkflowName clears the value of the "workflow_name" field.
func (u *CIWorkflowResultUpsert) ClearWorkflowName() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldWorkflowName)
	return u
}

// SetRunID sets the "run_id" field.
func (u *CIWorkflowResultUpsert) SetRunID(v string) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldRunID, v)
	return u
}

// UpdateRunID sets the "run_id" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateRunID() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldRunID)
	return u
}

// ClearRunID clears the value of the "run_id" field.
func (u *CIWorkflowResultUpsert) ClearRunID() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldRunID)
	return u
}

// SetJobID sets the "job_id" field.
func (u *CIWorkflowResultUpsert) SetJobID(v string) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldJobID, v)
	return u
}

// UpdateJobID sets the "job_id" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateJobID() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldJobID)
	return u
}

// ClearJobID clears the value of the "job_id" field.
func (u *CIWorkflowResultUpsert) ClearJobID() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldJobID)
	return u
}

// SetStatus sets the "status" field.
func (u *CIWorkflowResultUpsert) SetStatus(v schema.WorkflowRunStatusType) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldStatus, v)
	return u
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateStatus() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldStatus)
	return u
}

// SetStartTime sets the "start_time" field.
func (u *CIWorkflowResultUpsert) SetStartTime(v int64) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldStartTime, v)
	return u
}

// UpdateStartTime sets the "start_time" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateStartTime() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldStartTime)
	return u
}

// AddStartTime adds v to the "start_time" field.
func (u *CIWorkflowResultUpsert) AddStartTime(v int64) *CIWorkflowResultUpsert {
	u.Add(ciworkflowresult.FieldStartTime, v)
	return u
}

// ClearStartTime clears the value of the "start_time" field.
func (u *CIWorkflowResultUpsert) ClearStartTime() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldStartTime)
	return u
}

// SetEndTime sets the "end_time" field.
func (u *CIWorkflowResultUpsert) SetEndTime(v int64) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldEndTime, v)
	return u
}

// UpdateEndTime sets the "end_time" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateEndTime() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldEndTime)
	return u
}

// AddEndTime adds v to the "end_time" field.
func (u *CIWorkflowResultUpsert) AddEndTime(v int64) *CIWorkflowResultUpsert {
	u.Add(ciworkflowresult.FieldEndTime, v)
	return u
}

// ClearEndTime clears the value of the "end_time" field.
func (u *CIWorkflowResultUpsert) ClearEndTime() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldEndTime)
	return u
}

// SetPythonVersion sets the "python_version" field.
func (u *CIWorkflowResultUpsert) SetPythonVersion(v string) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldPythonVersion, v)
	return u
}

// UpdatePythonVersion sets the "python_version" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdatePythonVersion() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldPythonVersion)
	return u
}

// ClearPythonVersion clears the value of the "python_version" field.
func (u *CIWorkflowResultUpsert) ClearPythonVersion() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldPythonVersion)
	return u
}

// SetPytorchVersion sets the "pytorch_version" field.
func (u *CIWorkflowResultUpsert) SetPytorchVersion(v string) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldPytorchVersion, v)
	return u
}

// UpdatePytorchVersion sets the "pytorch_version" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdatePytorchVersion() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldPytorchVersion)
	return u
}

// ClearPytorchVersion clears the value of the "pytorch_version" field.
func (u *CIWorkflowResultUpsert) ClearPytorchVersion() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldPytorchVersion)
	return u
}

// SetCudaVersion sets the "cuda_version" field.
func (u *CIWorkflowResultUpsert) SetCudaVersion(v string) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldCudaVersion, v)
	return u
}

// UpdateCudaVersion sets the "cuda_version" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateCudaVersion() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldCudaVersion)
	return u
}

// ClearCudaVersion clears the value of the "cuda_version" field.
func (u *CIWorkflowResultUpsert) ClearCudaVersion() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldCudaVersion)
	return u
}

// SetComfyRunFlags sets the "comfy_run_flags" field.
func (u *CIWorkflowResultUpsert) SetComfyRunFlags(v string) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldComfyRunFlags, v)
	return u
}

// UpdateComfyRunFlags sets the "comfy_run_flags" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateComfyRunFlags() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldComfyRunFlags)
	return u
}

// ClearComfyRunFlags clears the value of the "comfy_run_flags" field.
func (u *CIWorkflowResultUpsert) ClearComfyRunFlags() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldComfyRunFlags)
	return u
}

// SetAvgVram sets the "avg_vram" field.
func (u *CIWorkflowResultUpsert) SetAvgVram(v int) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldAvgVram, v)
	return u
}

// UpdateAvgVram sets the "avg_vram" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateAvgVram() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldAvgVram)
	return u
}

// AddAvgVram adds v to the "avg_vram" field.
func (u *CIWorkflowResultUpsert) AddAvgVram(v int) *CIWorkflowResultUpsert {
	u.Add(ciworkflowresult.FieldAvgVram, v)
	return u
}

// ClearAvgVram clears the value of the "avg_vram" field.
func (u *CIWorkflowResultUpsert) ClearAvgVram() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldAvgVram)
	return u
}

// SetPeakVram sets the "peak_vram" field.
func (u *CIWorkflowResultUpsert) SetPeakVram(v int) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldPeakVram, v)
	return u
}

// UpdatePeakVram sets the "peak_vram" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdatePeakVram() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldPeakVram)
	return u
}

// AddPeakVram adds v to the "peak_vram" field.
func (u *CIWorkflowResultUpsert) AddPeakVram(v int) *CIWorkflowResultUpsert {
	u.Add(ciworkflowresult.FieldPeakVram, v)
	return u
}

// ClearPeakVram clears the value of the "peak_vram" field.
func (u *CIWorkflowResultUpsert) ClearPeakVram() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldPeakVram)
	return u
}

// SetJobTriggerUser sets the "job_trigger_user" field.
func (u *CIWorkflowResultUpsert) SetJobTriggerUser(v string) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldJobTriggerUser, v)
	return u
}

// UpdateJobTriggerUser sets the "job_trigger_user" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateJobTriggerUser() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldJobTriggerUser)
	return u
}

// ClearJobTriggerUser clears the value of the "job_trigger_user" field.
func (u *CIWorkflowResultUpsert) ClearJobTriggerUser() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldJobTriggerUser)
	return u
}

// SetMetadata sets the "metadata" field.
func (u *CIWorkflowResultUpsert) SetMetadata(v map[string]interface{}) *CIWorkflowResultUpsert {
	u.Set(ciworkflowresult.FieldMetadata, v)
	return u
}

// UpdateMetadata sets the "metadata" field to the value that was provided on create.
func (u *CIWorkflowResultUpsert) UpdateMetadata() *CIWorkflowResultUpsert {
	u.SetExcluded(ciworkflowresult.FieldMetadata)
	return u
}

// ClearMetadata clears the value of the "metadata" field.
func (u *CIWorkflowResultUpsert) ClearMetadata() *CIWorkflowResultUpsert {
	u.SetNull(ciworkflowresult.FieldMetadata)
	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:
//
//	client.CIWorkflowResult.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(ciworkflowresult.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *CIWorkflowResultUpsertOne) UpdateNewValues() *CIWorkflowResultUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		if _, exists := u.create.mutation.ID(); exists {
			s.SetIgnore(ciworkflowresult.FieldID)
		}
		if _, exists := u.create.mutation.CreateTime(); exists {
			s.SetIgnore(ciworkflowresult.FieldCreateTime)
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.CIWorkflowResult.Create().
//	    OnConflict(sql.ResolveWithIgnore()).
//	    Exec(ctx)
func (u *CIWorkflowResultUpsertOne) Ignore() *CIWorkflowResultUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
	return u
}

// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *CIWorkflowResultUpsertOne) DoNothing() *CIWorkflowResultUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the CIWorkflowResultCreate.OnConflict
// documentation for more info.
func (u *CIWorkflowResultUpsertOne) Update(set func(*CIWorkflowResultUpsert)) *CIWorkflowResultUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&CIWorkflowResultUpsert{UpdateSet: update})
	}))
	return u
}

// SetUpdateTime sets the "update_time" field.
func (u *CIWorkflowResultUpsertOne) SetUpdateTime(v time.Time) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetUpdateTime(v)
	})
}

// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateUpdateTime() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateUpdateTime()
	})
}

// SetOperatingSystem sets the "operating_system" field.
func (u *CIWorkflowResultUpsertOne) SetOperatingSystem(v string) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetOperatingSystem(v)
	})
}

// UpdateOperatingSystem sets the "operating_system" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateOperatingSystem() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateOperatingSystem()
	})
}

// SetWorkflowName sets the "workflow_name" field.
func (u *CIWorkflowResultUpsertOne) SetWorkflowName(v string) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetWorkflowName(v)
	})
}

// UpdateWorkflowName sets the "workflow_name" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateWorkflowName() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateWorkflowName()
	})
}

// ClearWorkflowName clears the value of the "workflow_name" field.
func (u *CIWorkflowResultUpsertOne) ClearWorkflowName() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearWorkflowName()
	})
}

// SetRunID sets the "run_id" field.
func (u *CIWorkflowResultUpsertOne) SetRunID(v string) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetRunID(v)
	})
}

// UpdateRunID sets the "run_id" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateRunID() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateRunID()
	})
}

// ClearRunID clears the value of the "run_id" field.
func (u *CIWorkflowResultUpsertOne) ClearRunID() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearRunID()
	})
}

// SetJobID sets the "job_id" field.
func (u *CIWorkflowResultUpsertOne) SetJobID(v string) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetJobID(v)
	})
}

// UpdateJobID sets the "job_id" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateJobID() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateJobID()
	})
}

// ClearJobID clears the value of the "job_id" field.
func (u *CIWorkflowResultUpsertOne) ClearJobID() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearJobID()
	})
}

// SetStatus sets the "status" field.
func (u *CIWorkflowResultUpsertOne) SetStatus(v schema.WorkflowRunStatusType) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetStatus(v)
	})
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateStatus() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateStatus()
	})
}

// SetStartTime sets the "start_time" field.
func (u *CIWorkflowResultUpsertOne) SetStartTime(v int64) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetStartTime(v)
	})
}

// AddStartTime adds v to the "start_time" field.
func (u *CIWorkflowResultUpsertOne) AddStartTime(v int64) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.AddStartTime(v)
	})
}

// UpdateStartTime sets the "start_time" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateStartTime() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateStartTime()
	})
}

// ClearStartTime clears the value of the "start_time" field.
func (u *CIWorkflowResultUpsertOne) ClearStartTime() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearStartTime()
	})
}

// SetEndTime sets the "end_time" field.
func (u *CIWorkflowResultUpsertOne) SetEndTime(v int64) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetEndTime(v)
	})
}

// AddEndTime adds v to the "end_time" field.
func (u *CIWorkflowResultUpsertOne) AddEndTime(v int64) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.AddEndTime(v)
	})
}

// UpdateEndTime sets the "end_time" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateEndTime() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateEndTime()
	})
}

// ClearEndTime clears the value of the "end_time" field.
func (u *CIWorkflowResultUpsertOne) ClearEndTime() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearEndTime()
	})
}

// SetPythonVersion sets the "python_version" field.
func (u *CIWorkflowResultUpsertOne) SetPythonVersion(v string) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetPythonVersion(v)
	})
}

// UpdatePythonVersion sets the "python_version" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdatePythonVersion() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdatePythonVersion()
	})
}

// ClearPythonVersion clears the value of the "python_version" field.
func (u *CIWorkflowResultUpsertOne) ClearPythonVersion() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearPythonVersion()
	})
}

// SetPytorchVersion sets the "pytorch_version" field.
func (u *CIWorkflowResultUpsertOne) SetPytorchVersion(v string) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetPytorchVersion(v)
	})
}

// UpdatePytorchVersion sets the "pytorch_version" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdatePytorchVersion() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdatePytorchVersion()
	})
}

// ClearPytorchVersion clears the value of the "pytorch_version" field.
func (u *CIWorkflowResultUpsertOne) ClearPytorchVersion() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearPytorchVersion()
	})
}

// SetCudaVersion sets the "cuda_version" field.
func (u *CIWorkflowResultUpsertOne) SetCudaVersion(v string) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetCudaVersion(v)
	})
}

// UpdateCudaVersion sets the "cuda_version" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateCudaVersion() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateCudaVersion()
	})
}

// ClearCudaVersion clears the value of the "cuda_version" field.
func (u *CIWorkflowResultUpsertOne) ClearCudaVersion() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearCudaVersion()
	})
}

// SetComfyRunFlags sets the "comfy_run_flags" field.
func (u *CIWorkflowResultUpsertOne) SetComfyRunFlags(v string) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetComfyRunFlags(v)
	})
}

// UpdateComfyRunFlags sets the "comfy_run_flags" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateComfyRunFlags() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateComfyRunFlags()
	})
}

// ClearComfyRunFlags clears the value of the "comfy_run_flags" field.
func (u *CIWorkflowResultUpsertOne) ClearComfyRunFlags() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearComfyRunFlags()
	})
}

// SetAvgVram sets the "avg_vram" field.
func (u *CIWorkflowResultUpsertOne) SetAvgVram(v int) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetAvgVram(v)
	})
}

// AddAvgVram adds v to the "avg_vram" field.
func (u *CIWorkflowResultUpsertOne) AddAvgVram(v int) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.AddAvgVram(v)
	})
}

// UpdateAvgVram sets the "avg_vram" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateAvgVram() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateAvgVram()
	})
}

// ClearAvgVram clears the value of the "avg_vram" field.
func (u *CIWorkflowResultUpsertOne) ClearAvgVram() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearAvgVram()
	})
}

// SetPeakVram sets the "peak_vram" field.
func (u *CIWorkflowResultUpsertOne) SetPeakVram(v int) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetPeakVram(v)
	})
}

// AddPeakVram adds v to the "peak_vram" field.
func (u *CIWorkflowResultUpsertOne) AddPeakVram(v int) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.AddPeakVram(v)
	})
}

// UpdatePeakVram sets the "peak_vram" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdatePeakVram() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdatePeakVram()
	})
}

// ClearPeakVram clears the value of the "peak_vram" field.
func (u *CIWorkflowResultUpsertOne) ClearPeakVram() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearPeakVram()
	})
}

// SetJobTriggerUser sets the "job_trigger_user" field.
func (u *CIWorkflowResultUpsertOne) SetJobTriggerUser(v string) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetJobTriggerUser(v)
	})
}

// UpdateJobTriggerUser sets the "job_trigger_user" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateJobTriggerUser() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateJobTriggerUser()
	})
}

// ClearJobTriggerUser clears the value of the "job_trigger_user" field.
func (u *CIWorkflowResultUpsertOne) ClearJobTriggerUser() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearJobTriggerUser()
	})
}

// SetMetadata sets the "metadata" field.
func (u *CIWorkflowResultUpsertOne) SetMetadata(v map[string]interface{}) *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetMetadata(v)
	})
}

// UpdateMetadata sets the "metadata" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertOne) UpdateMetadata() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateMetadata()
	})
}

// ClearMetadata clears the value of the "metadata" field.
func (u *CIWorkflowResultUpsertOne) ClearMetadata() *CIWorkflowResultUpsertOne {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearMetadata()
	})
}

// Exec executes the query.
func (u *CIWorkflowResultUpsertOne) Exec(ctx context.Context) error {
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for CIWorkflowResultCreate.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *CIWorkflowResultUpsertOne) ExecX(ctx context.Context) {
	if err := u.create.Exec(ctx); err != nil {
		panic(err)
	}
}

// Exec executes the UPSERT query and returns the inserted/updated ID.
func (u *CIWorkflowResultUpsertOne) ID(ctx context.Context) (id uuid.UUID, err error) {
	if u.create.driver.Dialect() == dialect.MySQL {
		// In case of "ON CONFLICT", there is no way to get back non-numeric ID
		// fields from the database since MySQL does not support the RETURNING clause.
		return id, errors.New("ent: CIWorkflowResultUpsertOne.ID is not supported by MySQL driver. Use CIWorkflowResultUpsertOne.Exec instead")
	}
	node, err := u.create.Save(ctx)
	if err != nil {
		return id, err
	}
	return node.ID, nil
}

// IDX is like ID, but panics if an error occurs.
func (u *CIWorkflowResultUpsertOne) IDX(ctx context.Context) uuid.UUID {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

// CIWorkflowResultCreateBulk is the builder for creating many CIWorkflowResult entities in bulk.
type CIWorkflowResultCreateBulk struct {
	config
	err      error
	builders []*CIWorkflowResultCreate
	conflict []sql.ConflictOption
}

// Save creates the CIWorkflowResult entities in the database.
func (cwrcb *CIWorkflowResultCreateBulk) Save(ctx context.Context) ([]*CIWorkflowResult, error) {
	if cwrcb.err != nil {
		return nil, cwrcb.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(cwrcb.builders))
	nodes := make([]*CIWorkflowResult, len(cwrcb.builders))
	mutators := make([]Mutator, len(cwrcb.builders))
	for i := range cwrcb.builders {
		func(i int, root context.Context) {
			builder := cwrcb.builders[i]
			builder.defaults()
			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
				mutation, ok := m.(*CIWorkflowResultMutation)
				if !ok {
					return nil, fmt.Errorf("unexpected mutation type %T", m)
				}
				if err := builder.check(); err != nil {
					return nil, err
				}
				builder.mutation = mutation
				var err error
				nodes[i], specs[i] = builder.createSpec()
				if i < len(mutators)-1 {
					_, err = mutators[i+1].Mutate(root, cwrcb.builders[i+1].mutation)
				} else {
					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
					spec.OnConflict = cwrcb.conflict
					// Invoke the actual operation on the latest mutation in the chain.
					if err = sqlgraph.BatchCreate(ctx, cwrcb.driver, spec); err != nil {
						if sqlgraph.IsConstraintError(err) {
							err = &ConstraintError{msg: err.Error(), wrap: err}
						}
					}
				}
				if err != nil {
					return nil, err
				}
				mutation.id = &nodes[i].ID
				mutation.done = true
				return nodes[i], nil
			})
			for i := len(builder.hooks) - 1; i >= 0; i-- {
				mut = builder.hooks[i](mut)
			}
			mutators[i] = mut
		}(i, ctx)
	}
	if len(mutators) > 0 {
		if _, err := mutators[0].Mutate(ctx, cwrcb.builders[0].mutation); err != nil {
			return nil, err
		}
	}
	return nodes, nil
}

// SaveX is like Save, but panics if an error occurs.
func (cwrcb *CIWorkflowResultCreateBulk) SaveX(ctx context.Context) []*CIWorkflowResult {
	v, err := cwrcb.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

// Exec executes the query.
func (cwrcb *CIWorkflowResultCreateBulk) Exec(ctx context.Context) error {
	_, err := cwrcb.Save(ctx)
	return err
}

// ExecX is like Exec, but panics if an error occurs.
func (cwrcb *CIWorkflowResultCreateBulk) ExecX(ctx context.Context) {
	if err := cwrcb.Exec(ctx); err != nil {
		panic(err)
	}
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.CIWorkflowResult.CreateBulk(builders...).
//		OnConflict(
//			// Update the row with the new values
//			// the was proposed for insertion.
//			sql.ResolveWithNewValues(),
//		).
//		// Override some of the fields with custom
//		// update values.
//		Update(func(u *ent.CIWorkflowResultUpsert) {
//			SetCreateTime(v+v).
//		}).
//		Exec(ctx)
func (cwrcb *CIWorkflowResultCreateBulk) OnConflict(opts ...sql.ConflictOption) *CIWorkflowResultUpsertBulk {
	cwrcb.conflict = opts
	return &CIWorkflowResultUpsertBulk{
		create: cwrcb,
	}
}

// OnConflictColumns calls `OnConflict` and configures the columns
// as conflict target. Using this option is equivalent to using:
//
//	client.CIWorkflowResult.Create().
//		OnConflict(sql.ConflictColumns(columns...)).
//		Exec(ctx)
func (cwrcb *CIWorkflowResultCreateBulk) OnConflictColumns(columns ...string) *CIWorkflowResultUpsertBulk {
	cwrcb.conflict = append(cwrcb.conflict, sql.ConflictColumns(columns...))
	return &CIWorkflowResultUpsertBulk{
		create: cwrcb,
	}
}

// CIWorkflowResultUpsertBulk is the builder for "upsert"-ing
// a bulk of CIWorkflowResult nodes.
type CIWorkflowResultUpsertBulk struct {
	create *CIWorkflowResultCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.CIWorkflowResult.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(ciworkflowresult.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *CIWorkflowResultUpsertBulk) UpdateNewValues() *CIWorkflowResultUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		for _, b := range u.create.builders {
			if _, exists := b.mutation.ID(); exists {
				s.SetIgnore(ciworkflowresult.FieldID)
			}
			if _, exists := b.mutation.CreateTime(); exists {
				s.SetIgnore(ciworkflowresult.FieldCreateTime)
			}
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.CIWorkflowResult.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
func (u *CIWorkflowResultUpsertBulk) Ignore() *CIWorkflowResultUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
	return u
}

// DoNothing configures the conflict_action to `DO NOTHING`.
// Supported only by SQLite and PostgreSQL.
func (u *CIWorkflowResultUpsertBulk) DoNothing() *CIWorkflowResultUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

// Update allows overriding fields `UPDATE` values. See the CIWorkflowResultCreateBulk.OnConflict
// documentation for more info.
func (u *CIWorkflowResultUpsertBulk) Update(set func(*CIWorkflowResultUpsert)) *CIWorkflowResultUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
		set(&CIWorkflowResultUpsert{UpdateSet: update})
	}))
	return u
}

// SetUpdateTime sets the "update_time" field.
func (u *CIWorkflowResultUpsertBulk) SetUpdateTime(v time.Time) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetUpdateTime(v)
	})
}

// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateUpdateTime() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateUpdateTime()
	})
}

// SetOperatingSystem sets the "operating_system" field.
func (u *CIWorkflowResultUpsertBulk) SetOperatingSystem(v string) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetOperatingSystem(v)
	})
}

// UpdateOperatingSystem sets the "operating_system" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateOperatingSystem() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateOperatingSystem()
	})
}

// SetWorkflowName sets the "workflow_name" field.
func (u *CIWorkflowResultUpsertBulk) SetWorkflowName(v string) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetWorkflowName(v)
	})
}

// UpdateWorkflowName sets the "workflow_name" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateWorkflowName() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateWorkflowName()
	})
}

// ClearWorkflowName clears the value of the "workflow_name" field.
func (u *CIWorkflowResultUpsertBulk) ClearWorkflowName() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearWorkflowName()
	})
}

// SetRunID sets the "run_id" field.
func (u *CIWorkflowResultUpsertBulk) SetRunID(v string) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetRunID(v)
	})
}

// UpdateRunID sets the "run_id" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateRunID() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateRunID()
	})
}

// ClearRunID clears the value of the "run_id" field.
func (u *CIWorkflowResultUpsertBulk) ClearRunID() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearRunID()
	})
}

// SetJobID sets the "job_id" field.
func (u *CIWorkflowResultUpsertBulk) SetJobID(v string) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetJobID(v)
	})
}

// UpdateJobID sets the "job_id" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateJobID() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateJobID()
	})
}

// ClearJobID clears the value of the "job_id" field.
func (u *CIWorkflowResultUpsertBulk) ClearJobID() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearJobID()
	})
}

// SetStatus sets the "status" field.
func (u *CIWorkflowResultUpsertBulk) SetStatus(v schema.WorkflowRunStatusType) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetStatus(v)
	})
}

// UpdateStatus sets the "status" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateStatus() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateStatus()
	})
}

// SetStartTime sets the "start_time" field.
func (u *CIWorkflowResultUpsertBulk) SetStartTime(v int64) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetStartTime(v)
	})
}

// AddStartTime adds v to the "start_time" field.
func (u *CIWorkflowResultUpsertBulk) AddStartTime(v int64) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.AddStartTime(v)
	})
}

// UpdateStartTime sets the "start_time" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateStartTime() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateStartTime()
	})
}

// ClearStartTime clears the value of the "start_time" field.
func (u *CIWorkflowResultUpsertBulk) ClearStartTime() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearStartTime()
	})
}

// SetEndTime sets the "end_time" field.
func (u *CIWorkflowResultUpsertBulk) SetEndTime(v int64) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetEndTime(v)
	})
}

// AddEndTime adds v to the "end_time" field.
func (u *CIWorkflowResultUpsertBulk) AddEndTime(v int64) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.AddEndTime(v)
	})
}

// UpdateEndTime sets the "end_time" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateEndTime() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateEndTime()
	})
}

// ClearEndTime clears the value of the "end_time" field.
func (u *CIWorkflowResultUpsertBulk) ClearEndTime() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearEndTime()
	})
}

// SetPythonVersion sets the "python_version" field.
func (u *CIWorkflowResultUpsertBulk) SetPythonVersion(v string) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetPythonVersion(v)
	})
}

// UpdatePythonVersion sets the "python_version" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdatePythonVersion() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdatePythonVersion()
	})
}

// ClearPythonVersion clears the value of the "python_version" field.
func (u *CIWorkflowResultUpsertBulk) ClearPythonVersion() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearPythonVersion()
	})
}

// SetPytorchVersion sets the "pytorch_version" field.
func (u *CIWorkflowResultUpsertBulk) SetPytorchVersion(v string) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetPytorchVersion(v)
	})
}

// UpdatePytorchVersion sets the "pytorch_version" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdatePytorchVersion() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdatePytorchVersion()
	})
}

// ClearPytorchVersion clears the value of the "pytorch_version" field.
func (u *CIWorkflowResultUpsertBulk) ClearPytorchVersion() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearPytorchVersion()
	})
}

// SetCudaVersion sets the "cuda_version" field.
func (u *CIWorkflowResultUpsertBulk) SetCudaVersion(v string) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetCudaVersion(v)
	})
}

// UpdateCudaVersion sets the "cuda_version" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateCudaVersion() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateCudaVersion()
	})
}

// ClearCudaVersion clears the value of the "cuda_version" field.
func (u *CIWorkflowResultUpsertBulk) ClearCudaVersion() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearCudaVersion()
	})
}

// SetComfyRunFlags sets the "comfy_run_flags" field.
func (u *CIWorkflowResultUpsertBulk) SetComfyRunFlags(v string) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetComfyRunFlags(v)
	})
}

// UpdateComfyRunFlags sets the "comfy_run_flags" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateComfyRunFlags() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateComfyRunFlags()
	})
}

// ClearComfyRunFlags clears the value of the "comfy_run_flags" field.
func (u *CIWorkflowResultUpsertBulk) ClearComfyRunFlags() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearComfyRunFlags()
	})
}

// SetAvgVram sets the "avg_vram" field.
func (u *CIWorkflowResultUpsertBulk) SetAvgVram(v int) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetAvgVram(v)
	})
}

// AddAvgVram adds v to the "avg_vram" field.
func (u *CIWorkflowResultUpsertBulk) AddAvgVram(v int) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.AddAvgVram(v)
	})
}

// UpdateAvgVram sets the "avg_vram" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateAvgVram() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateAvgVram()
	})
}

// ClearAvgVram clears the value of the "avg_vram" field.
func (u *CIWorkflowResultUpsertBulk) ClearAvgVram() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearAvgVram()
	})
}

// SetPeakVram sets the "peak_vram" field.
func (u *CIWorkflowResultUpsertBulk) SetPeakVram(v int) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetPeakVram(v)
	})
}

// AddPeakVram adds v to the "peak_vram" field.
func (u *CIWorkflowResultUpsertBulk) AddPeakVram(v int) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.AddPeakVram(v)
	})
}

// UpdatePeakVram sets the "peak_vram" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdatePeakVram() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdatePeakVram()
	})
}

// ClearPeakVram clears the value of the "peak_vram" field.
func (u *CIWorkflowResultUpsertBulk) ClearPeakVram() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearPeakVram()
	})
}

// SetJobTriggerUser sets the "job_trigger_user" field.
func (u *CIWorkflowResultUpsertBulk) SetJobTriggerUser(v string) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetJobTriggerUser(v)
	})
}

// UpdateJobTriggerUser sets the "job_trigger_user" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateJobTriggerUser() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateJobTriggerUser()
	})
}

// ClearJobTriggerUser clears the value of the "job_trigger_user" field.
func (u *CIWorkflowResultUpsertBulk) ClearJobTriggerUser() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearJobTriggerUser()
	})
}

// SetMetadata sets the "metadata" field.
func (u *CIWorkflowResultUpsertBulk) SetMetadata(v map[string]interface{}) *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.SetMetadata(v)
	})
}

// UpdateMetadata sets the "metadata" field to the value that was provided on create.
func (u *CIWorkflowResultUpsertBulk) UpdateMetadata() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.UpdateMetadata()
	})
}

// ClearMetadata clears the value of the "metadata" field.
func (u *CIWorkflowResultUpsertBulk) ClearMetadata() *CIWorkflowResultUpsertBulk {
	return u.Update(func(s *CIWorkflowResultUpsert) {
		s.ClearMetadata()
	})
}

// Exec executes the query.
func (u *CIWorkflowResultUpsertBulk) Exec(ctx context.Context) error {
	if u.create.err != nil {
		return u.create.err
	}
	for i, b := range u.create.builders {
		if len(b.conflict) != 0 {
			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the CIWorkflowResultCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for CIWorkflowResultCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

// ExecX is like Exec, but panics if an error occurs.
func (u *CIWorkflowResultUpsertBulk) ExecX(ctx context.Context) {
	if err := u.create.Exec(ctx); err != nil {
		panic(err)
	}
}
