// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"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"
	"github.com/lightsparkdev/spark/so/ent/cooperativeexit"
	"github.com/lightsparkdev/spark/so/ent/transfer"
)

// CooperativeExitCreate is the builder for creating a CooperativeExit entity.
type CooperativeExitCreate struct {
	config
	mutation *CooperativeExitMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

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

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

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

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

// SetExitTxid sets the "exit_txid" field.
func (cec *CooperativeExitCreate) SetExitTxid(b []byte) *CooperativeExitCreate {
	cec.mutation.SetExitTxid(b)
	return cec
}

// SetConfirmationHeight sets the "confirmation_height" field.
func (cec *CooperativeExitCreate) SetConfirmationHeight(i int64) *CooperativeExitCreate {
	cec.mutation.SetConfirmationHeight(i)
	return cec
}

// SetNillableConfirmationHeight sets the "confirmation_height" field if the given value is not nil.
func (cec *CooperativeExitCreate) SetNillableConfirmationHeight(i *int64) *CooperativeExitCreate {
	if i != nil {
		cec.SetConfirmationHeight(*i)
	}
	return cec
}

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

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

// SetTransferID sets the "transfer" edge to the Transfer entity by ID.
func (cec *CooperativeExitCreate) SetTransferID(id uuid.UUID) *CooperativeExitCreate {
	cec.mutation.SetTransferID(id)
	return cec
}

// SetTransfer sets the "transfer" edge to the Transfer entity.
func (cec *CooperativeExitCreate) SetTransfer(t *Transfer) *CooperativeExitCreate {
	return cec.SetTransferID(t.ID)
}

// Mutation returns the CooperativeExitMutation object of the builder.
func (cec *CooperativeExitCreate) Mutation() *CooperativeExitMutation {
	return cec.mutation
}

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

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

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

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

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

// check runs all checks and user-defined validators on the builder.
func (cec *CooperativeExitCreate) check() error {
	if _, ok := cec.mutation.CreateTime(); !ok {
		return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "CooperativeExit.create_time"`)}
	}
	if _, ok := cec.mutation.UpdateTime(); !ok {
		return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "CooperativeExit.update_time"`)}
	}
	if _, ok := cec.mutation.ExitTxid(); !ok {
		return &ValidationError{Name: "exit_txid", err: errors.New(`ent: missing required field "CooperativeExit.exit_txid"`)}
	}
	if len(cec.mutation.TransferIDs()) == 0 {
		return &ValidationError{Name: "transfer", err: errors.New(`ent: missing required edge "CooperativeExit.transfer"`)}
	}
	return nil
}

func (cec *CooperativeExitCreate) sqlSave(ctx context.Context) (*CooperativeExit, error) {
	if err := cec.check(); err != nil {
		return nil, err
	}
	_node, _spec := cec.createSpec()
	if err := sqlgraph.CreateNode(ctx, cec.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
		}
	}
	cec.mutation.id = &_node.ID
	cec.mutation.done = true
	return _node, nil
}

func (cec *CooperativeExitCreate) createSpec() (*CooperativeExit, *sqlgraph.CreateSpec) {
	var (
		_node = &CooperativeExit{config: cec.config}
		_spec = sqlgraph.NewCreateSpec(cooperativeexit.Table, sqlgraph.NewFieldSpec(cooperativeexit.FieldID, field.TypeUUID))
	)
	_spec.OnConflict = cec.conflict
	if id, ok := cec.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = &id
	}
	if value, ok := cec.mutation.CreateTime(); ok {
		_spec.SetField(cooperativeexit.FieldCreateTime, field.TypeTime, value)
		_node.CreateTime = value
	}
	if value, ok := cec.mutation.UpdateTime(); ok {
		_spec.SetField(cooperativeexit.FieldUpdateTime, field.TypeTime, value)
		_node.UpdateTime = value
	}
	if value, ok := cec.mutation.ExitTxid(); ok {
		_spec.SetField(cooperativeexit.FieldExitTxid, field.TypeBytes, value)
		_node.ExitTxid = value
	}
	if value, ok := cec.mutation.ConfirmationHeight(); ok {
		_spec.SetField(cooperativeexit.FieldConfirmationHeight, field.TypeInt64, value)
		_node.ConfirmationHeight = value
	}
	if nodes := cec.mutation.TransferIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: false,
			Table:   cooperativeexit.TransferTable,
			Columns: []string{cooperativeexit.TransferColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(transfer.FieldID, field.TypeUUID),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.cooperative_exit_transfer = &nodes[0]
		_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.CooperativeExit.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.CooperativeExitUpsert) {
//			SetCreateTime(v+v).
//		}).
//		Exec(ctx)
func (cec *CooperativeExitCreate) OnConflict(opts ...sql.ConflictOption) *CooperativeExitUpsertOne {
	cec.conflict = opts
	return &CooperativeExitUpsertOne{
		create: cec,
	}
}

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

type (
	// CooperativeExitUpsertOne is the builder for "upsert"-ing
	//  one CooperativeExit node.
	CooperativeExitUpsertOne struct {
		create *CooperativeExitCreate
	}

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

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

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

// SetConfirmationHeight sets the "confirmation_height" field.
func (u *CooperativeExitUpsert) SetConfirmationHeight(v int64) *CooperativeExitUpsert {
	u.Set(cooperativeexit.FieldConfirmationHeight, v)
	return u
}

// UpdateConfirmationHeight sets the "confirmation_height" field to the value that was provided on create.
func (u *CooperativeExitUpsert) UpdateConfirmationHeight() *CooperativeExitUpsert {
	u.SetExcluded(cooperativeexit.FieldConfirmationHeight)
	return u
}

// AddConfirmationHeight adds v to the "confirmation_height" field.
func (u *CooperativeExitUpsert) AddConfirmationHeight(v int64) *CooperativeExitUpsert {
	u.Add(cooperativeexit.FieldConfirmationHeight, v)
	return u
}

// ClearConfirmationHeight clears the value of the "confirmation_height" field.
func (u *CooperativeExitUpsert) ClearConfirmationHeight() *CooperativeExitUpsert {
	u.SetNull(cooperativeexit.FieldConfirmationHeight)
	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.CooperativeExit.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(cooperativeexit.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *CooperativeExitUpsertOne) UpdateNewValues() *CooperativeExitUpsertOne {
	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(cooperativeexit.FieldID)
		}
		if _, exists := u.create.mutation.CreateTime(); exists {
			s.SetIgnore(cooperativeexit.FieldCreateTime)
		}
		if _, exists := u.create.mutation.ExitTxid(); exists {
			s.SetIgnore(cooperativeexit.FieldExitTxid)
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.CooperativeExit.Create().
//	    OnConflict(sql.ResolveWithIgnore()).
//	    Exec(ctx)
func (u *CooperativeExitUpsertOne) Ignore() *CooperativeExitUpsertOne {
	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 *CooperativeExitUpsertOne) DoNothing() *CooperativeExitUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

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

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

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

// SetConfirmationHeight sets the "confirmation_height" field.
func (u *CooperativeExitUpsertOne) SetConfirmationHeight(v int64) *CooperativeExitUpsertOne {
	return u.Update(func(s *CooperativeExitUpsert) {
		s.SetConfirmationHeight(v)
	})
}

// AddConfirmationHeight adds v to the "confirmation_height" field.
func (u *CooperativeExitUpsertOne) AddConfirmationHeight(v int64) *CooperativeExitUpsertOne {
	return u.Update(func(s *CooperativeExitUpsert) {
		s.AddConfirmationHeight(v)
	})
}

// UpdateConfirmationHeight sets the "confirmation_height" field to the value that was provided on create.
func (u *CooperativeExitUpsertOne) UpdateConfirmationHeight() *CooperativeExitUpsertOne {
	return u.Update(func(s *CooperativeExitUpsert) {
		s.UpdateConfirmationHeight()
	})
}

// ClearConfirmationHeight clears the value of the "confirmation_height" field.
func (u *CooperativeExitUpsertOne) ClearConfirmationHeight() *CooperativeExitUpsertOne {
	return u.Update(func(s *CooperativeExitUpsert) {
		s.ClearConfirmationHeight()
	})
}

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

// ExecX is like Exec, but panics if an error occurs.
func (u *CooperativeExitUpsertOne) 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 *CooperativeExitUpsertOne) 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: CooperativeExitUpsertOne.ID is not supported by MySQL driver. Use CooperativeExitUpsertOne.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 *CooperativeExitUpsertOne) IDX(ctx context.Context) uuid.UUID {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

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

// Save creates the CooperativeExit entities in the database.
func (cecb *CooperativeExitCreateBulk) Save(ctx context.Context) ([]*CooperativeExit, error) {
	if cecb.err != nil {
		return nil, cecb.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(cecb.builders))
	nodes := make([]*CooperativeExit, len(cecb.builders))
	mutators := make([]Mutator, len(cecb.builders))
	for i := range cecb.builders {
		func(i int, root context.Context) {
			builder := cecb.builders[i]
			builder.defaults()
			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
				mutation, ok := m.(*CooperativeExitMutation)
				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, cecb.builders[i+1].mutation)
				} else {
					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
					spec.OnConflict = cecb.conflict
					// Invoke the actual operation on the latest mutation in the chain.
					if err = sqlgraph.BatchCreate(ctx, cecb.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, cecb.builders[0].mutation); err != nil {
			return nil, err
		}
	}
	return nodes, nil
}

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

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

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

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.CooperativeExit.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.CooperativeExitUpsert) {
//			SetCreateTime(v+v).
//		}).
//		Exec(ctx)
func (cecb *CooperativeExitCreateBulk) OnConflict(opts ...sql.ConflictOption) *CooperativeExitUpsertBulk {
	cecb.conflict = opts
	return &CooperativeExitUpsertBulk{
		create: cecb,
	}
}

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

// CooperativeExitUpsertBulk is the builder for "upsert"-ing
// a bulk of CooperativeExit nodes.
type CooperativeExitUpsertBulk struct {
	create *CooperativeExitCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.CooperativeExit.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(cooperativeexit.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *CooperativeExitUpsertBulk) UpdateNewValues() *CooperativeExitUpsertBulk {
	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(cooperativeexit.FieldID)
			}
			if _, exists := b.mutation.CreateTime(); exists {
				s.SetIgnore(cooperativeexit.FieldCreateTime)
			}
			if _, exists := b.mutation.ExitTxid(); exists {
				s.SetIgnore(cooperativeexit.FieldExitTxid)
			}
		}
	}))
	return u
}

// Ignore sets each column to itself in case of conflict.
// Using this option is equivalent to using:
//
//	client.CooperativeExit.Create().
//		OnConflict(sql.ResolveWithIgnore()).
//		Exec(ctx)
func (u *CooperativeExitUpsertBulk) Ignore() *CooperativeExitUpsertBulk {
	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 *CooperativeExitUpsertBulk) DoNothing() *CooperativeExitUpsertBulk {
	u.create.conflict = append(u.create.conflict, sql.DoNothing())
	return u
}

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

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

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

// SetConfirmationHeight sets the "confirmation_height" field.
func (u *CooperativeExitUpsertBulk) SetConfirmationHeight(v int64) *CooperativeExitUpsertBulk {
	return u.Update(func(s *CooperativeExitUpsert) {
		s.SetConfirmationHeight(v)
	})
}

// AddConfirmationHeight adds v to the "confirmation_height" field.
func (u *CooperativeExitUpsertBulk) AddConfirmationHeight(v int64) *CooperativeExitUpsertBulk {
	return u.Update(func(s *CooperativeExitUpsert) {
		s.AddConfirmationHeight(v)
	})
}

// UpdateConfirmationHeight sets the "confirmation_height" field to the value that was provided on create.
func (u *CooperativeExitUpsertBulk) UpdateConfirmationHeight() *CooperativeExitUpsertBulk {
	return u.Update(func(s *CooperativeExitUpsert) {
		s.UpdateConfirmationHeight()
	})
}

// ClearConfirmationHeight clears the value of the "confirmation_height" field.
func (u *CooperativeExitUpsertBulk) ClearConfirmationHeight() *CooperativeExitUpsertBulk {
	return u.Update(func(s *CooperativeExitUpsert) {
		s.ClearConfirmationHeight()
	})
}

// Exec executes the query.
func (u *CooperativeExitUpsertBulk) 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 CooperativeExitCreateBulk instead", i)
		}
	}
	if len(u.create.conflict) == 0 {
		return errors.New("ent: missing options for CooperativeExitCreateBulk.OnConflict")
	}
	return u.create.Exec(ctx)
}

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