// Code generated by ent, DO NOT EDIT.

package ent

import (
	"context"
	"errors"
	"fmt"
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"entgo.io/ent/schema/field"
	"github.com/Wei-Shaw/sub2api/ent/account"
	"github.com/Wei-Shaw/sub2api/ent/apikey"
	"github.com/Wei-Shaw/sub2api/ent/group"
	"github.com/Wei-Shaw/sub2api/ent/usagelog"
	"github.com/Wei-Shaw/sub2api/ent/user"
	"github.com/Wei-Shaw/sub2api/ent/usersubscription"
)

// UsageLogCreate is the builder for creating a UsageLog entity.
type UsageLogCreate struct {
	config
	mutation *UsageLogMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetUserID sets the "user_id" field.
func (_c *UsageLogCreate) SetUserID(v int64) *UsageLogCreate {
	_c.mutation.SetUserID(v)
	return _c
}

// SetAPIKeyID sets the "api_key_id" field.
func (_c *UsageLogCreate) SetAPIKeyID(v int64) *UsageLogCreate {
	_c.mutation.SetAPIKeyID(v)
	return _c
}

// SetAccountID sets the "account_id" field.
func (_c *UsageLogCreate) SetAccountID(v int64) *UsageLogCreate {
	_c.mutation.SetAccountID(v)
	return _c
}

// SetRequestID sets the "request_id" field.
func (_c *UsageLogCreate) SetRequestID(v string) *UsageLogCreate {
	_c.mutation.SetRequestID(v)
	return _c
}

// SetModel sets the "model" field.
func (_c *UsageLogCreate) SetModel(v string) *UsageLogCreate {
	_c.mutation.SetModel(v)
	return _c
}

// SetGroupID sets the "group_id" field.
func (_c *UsageLogCreate) SetGroupID(v int64) *UsageLogCreate {
	_c.mutation.SetGroupID(v)
	return _c
}

// SetNillableGroupID sets the "group_id" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableGroupID(v *int64) *UsageLogCreate {
	if v != nil {
		_c.SetGroupID(*v)
	}
	return _c
}

// SetSubscriptionID sets the "subscription_id" field.
func (_c *UsageLogCreate) SetSubscriptionID(v int64) *UsageLogCreate {
	_c.mutation.SetSubscriptionID(v)
	return _c
}

// SetNillableSubscriptionID sets the "subscription_id" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableSubscriptionID(v *int64) *UsageLogCreate {
	if v != nil {
		_c.SetSubscriptionID(*v)
	}
	return _c
}

// SetInputTokens sets the "input_tokens" field.
func (_c *UsageLogCreate) SetInputTokens(v int) *UsageLogCreate {
	_c.mutation.SetInputTokens(v)
	return _c
}

// SetNillableInputTokens sets the "input_tokens" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableInputTokens(v *int) *UsageLogCreate {
	if v != nil {
		_c.SetInputTokens(*v)
	}
	return _c
}

// SetOutputTokens sets the "output_tokens" field.
func (_c *UsageLogCreate) SetOutputTokens(v int) *UsageLogCreate {
	_c.mutation.SetOutputTokens(v)
	return _c
}

// SetNillableOutputTokens sets the "output_tokens" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableOutputTokens(v *int) *UsageLogCreate {
	if v != nil {
		_c.SetOutputTokens(*v)
	}
	return _c
}

// SetCacheCreationTokens sets the "cache_creation_tokens" field.
func (_c *UsageLogCreate) SetCacheCreationTokens(v int) *UsageLogCreate {
	_c.mutation.SetCacheCreationTokens(v)
	return _c
}

// SetNillableCacheCreationTokens sets the "cache_creation_tokens" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableCacheCreationTokens(v *int) *UsageLogCreate {
	if v != nil {
		_c.SetCacheCreationTokens(*v)
	}
	return _c
}

// SetCacheReadTokens sets the "cache_read_tokens" field.
func (_c *UsageLogCreate) SetCacheReadTokens(v int) *UsageLogCreate {
	_c.mutation.SetCacheReadTokens(v)
	return _c
}

// SetNillableCacheReadTokens sets the "cache_read_tokens" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableCacheReadTokens(v *int) *UsageLogCreate {
	if v != nil {
		_c.SetCacheReadTokens(*v)
	}
	return _c
}

// SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
func (_c *UsageLogCreate) SetCacheCreation5mTokens(v int) *UsageLogCreate {
	_c.mutation.SetCacheCreation5mTokens(v)
	return _c
}

// SetNillableCacheCreation5mTokens sets the "cache_creation_5m_tokens" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableCacheCreation5mTokens(v *int) *UsageLogCreate {
	if v != nil {
		_c.SetCacheCreation5mTokens(*v)
	}
	return _c
}

// SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
func (_c *UsageLogCreate) SetCacheCreation1hTokens(v int) *UsageLogCreate {
	_c.mutation.SetCacheCreation1hTokens(v)
	return _c
}

// SetNillableCacheCreation1hTokens sets the "cache_creation_1h_tokens" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableCacheCreation1hTokens(v *int) *UsageLogCreate {
	if v != nil {
		_c.SetCacheCreation1hTokens(*v)
	}
	return _c
}

// SetInputCost sets the "input_cost" field.
func (_c *UsageLogCreate) SetInputCost(v float64) *UsageLogCreate {
	_c.mutation.SetInputCost(v)
	return _c
}

// SetNillableInputCost sets the "input_cost" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableInputCost(v *float64) *UsageLogCreate {
	if v != nil {
		_c.SetInputCost(*v)
	}
	return _c
}

// SetOutputCost sets the "output_cost" field.
func (_c *UsageLogCreate) SetOutputCost(v float64) *UsageLogCreate {
	_c.mutation.SetOutputCost(v)
	return _c
}

// SetNillableOutputCost sets the "output_cost" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableOutputCost(v *float64) *UsageLogCreate {
	if v != nil {
		_c.SetOutputCost(*v)
	}
	return _c
}

// SetCacheCreationCost sets the "cache_creation_cost" field.
func (_c *UsageLogCreate) SetCacheCreationCost(v float64) *UsageLogCreate {
	_c.mutation.SetCacheCreationCost(v)
	return _c
}

// SetNillableCacheCreationCost sets the "cache_creation_cost" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableCacheCreationCost(v *float64) *UsageLogCreate {
	if v != nil {
		_c.SetCacheCreationCost(*v)
	}
	return _c
}

// SetCacheReadCost sets the "cache_read_cost" field.
func (_c *UsageLogCreate) SetCacheReadCost(v float64) *UsageLogCreate {
	_c.mutation.SetCacheReadCost(v)
	return _c
}

// SetNillableCacheReadCost sets the "cache_read_cost" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableCacheReadCost(v *float64) *UsageLogCreate {
	if v != nil {
		_c.SetCacheReadCost(*v)
	}
	return _c
}

// SetTotalCost sets the "total_cost" field.
func (_c *UsageLogCreate) SetTotalCost(v float64) *UsageLogCreate {
	_c.mutation.SetTotalCost(v)
	return _c
}

// SetNillableTotalCost sets the "total_cost" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableTotalCost(v *float64) *UsageLogCreate {
	if v != nil {
		_c.SetTotalCost(*v)
	}
	return _c
}

// SetActualCost sets the "actual_cost" field.
func (_c *UsageLogCreate) SetActualCost(v float64) *UsageLogCreate {
	_c.mutation.SetActualCost(v)
	return _c
}

// SetNillableActualCost sets the "actual_cost" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableActualCost(v *float64) *UsageLogCreate {
	if v != nil {
		_c.SetActualCost(*v)
	}
	return _c
}

// SetRateMultiplier sets the "rate_multiplier" field.
func (_c *UsageLogCreate) SetRateMultiplier(v float64) *UsageLogCreate {
	_c.mutation.SetRateMultiplier(v)
	return _c
}

// SetNillableRateMultiplier sets the "rate_multiplier" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableRateMultiplier(v *float64) *UsageLogCreate {
	if v != nil {
		_c.SetRateMultiplier(*v)
	}
	return _c
}

// SetBillingType sets the "billing_type" field.
func (_c *UsageLogCreate) SetBillingType(v int8) *UsageLogCreate {
	_c.mutation.SetBillingType(v)
	return _c
}

// SetNillableBillingType sets the "billing_type" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableBillingType(v *int8) *UsageLogCreate {
	if v != nil {
		_c.SetBillingType(*v)
	}
	return _c
}

// SetStream sets the "stream" field.
func (_c *UsageLogCreate) SetStream(v bool) *UsageLogCreate {
	_c.mutation.SetStream(v)
	return _c
}

// SetNillableStream sets the "stream" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableStream(v *bool) *UsageLogCreate {
	if v != nil {
		_c.SetStream(*v)
	}
	return _c
}

// SetDurationMs sets the "duration_ms" field.
func (_c *UsageLogCreate) SetDurationMs(v int) *UsageLogCreate {
	_c.mutation.SetDurationMs(v)
	return _c
}

// SetNillableDurationMs sets the "duration_ms" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableDurationMs(v *int) *UsageLogCreate {
	if v != nil {
		_c.SetDurationMs(*v)
	}
	return _c
}

// SetFirstTokenMs sets the "first_token_ms" field.
func (_c *UsageLogCreate) SetFirstTokenMs(v int) *UsageLogCreate {
	_c.mutation.SetFirstTokenMs(v)
	return _c
}

// SetNillableFirstTokenMs sets the "first_token_ms" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableFirstTokenMs(v *int) *UsageLogCreate {
	if v != nil {
		_c.SetFirstTokenMs(*v)
	}
	return _c
}

// SetImageCount sets the "image_count" field.
func (_c *UsageLogCreate) SetImageCount(v int) *UsageLogCreate {
	_c.mutation.SetImageCount(v)
	return _c
}

// SetNillableImageCount sets the "image_count" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableImageCount(v *int) *UsageLogCreate {
	if v != nil {
		_c.SetImageCount(*v)
	}
	return _c
}

// SetImageSize sets the "image_size" field.
func (_c *UsageLogCreate) SetImageSize(v string) *UsageLogCreate {
	_c.mutation.SetImageSize(v)
	return _c
}

// SetNillableImageSize sets the "image_size" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableImageSize(v *string) *UsageLogCreate {
	if v != nil {
		_c.SetImageSize(*v)
	}
	return _c
}

// SetCreatedAt sets the "created_at" field.
func (_c *UsageLogCreate) SetCreatedAt(v time.Time) *UsageLogCreate {
	_c.mutation.SetCreatedAt(v)
	return _c
}

// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
func (_c *UsageLogCreate) SetNillableCreatedAt(v *time.Time) *UsageLogCreate {
	if v != nil {
		_c.SetCreatedAt(*v)
	}
	return _c
}

// SetUser sets the "user" edge to the User entity.
func (_c *UsageLogCreate) SetUser(v *User) *UsageLogCreate {
	return _c.SetUserID(v.ID)
}

// SetAPIKey sets the "api_key" edge to the APIKey entity.
func (_c *UsageLogCreate) SetAPIKey(v *APIKey) *UsageLogCreate {
	return _c.SetAPIKeyID(v.ID)
}

// SetAccount sets the "account" edge to the Account entity.
func (_c *UsageLogCreate) SetAccount(v *Account) *UsageLogCreate {
	return _c.SetAccountID(v.ID)
}

// SetGroup sets the "group" edge to the Group entity.
func (_c *UsageLogCreate) SetGroup(v *Group) *UsageLogCreate {
	return _c.SetGroupID(v.ID)
}

// SetSubscription sets the "subscription" edge to the UserSubscription entity.
func (_c *UsageLogCreate) SetSubscription(v *UserSubscription) *UsageLogCreate {
	return _c.SetSubscriptionID(v.ID)
}

// Mutation returns the UsageLogMutation object of the builder.
func (_c *UsageLogCreate) Mutation() *UsageLogMutation {
	return _c.mutation
}

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

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

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

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

// defaults sets the default values of the builder before save.
func (_c *UsageLogCreate) defaults() {
	if _, ok := _c.mutation.InputTokens(); !ok {
		v := usagelog.DefaultInputTokens
		_c.mutation.SetInputTokens(v)
	}
	if _, ok := _c.mutation.OutputTokens(); !ok {
		v := usagelog.DefaultOutputTokens
		_c.mutation.SetOutputTokens(v)
	}
	if _, ok := _c.mutation.CacheCreationTokens(); !ok {
		v := usagelog.DefaultCacheCreationTokens
		_c.mutation.SetCacheCreationTokens(v)
	}
	if _, ok := _c.mutation.CacheReadTokens(); !ok {
		v := usagelog.DefaultCacheReadTokens
		_c.mutation.SetCacheReadTokens(v)
	}
	if _, ok := _c.mutation.CacheCreation5mTokens(); !ok {
		v := usagelog.DefaultCacheCreation5mTokens
		_c.mutation.SetCacheCreation5mTokens(v)
	}
	if _, ok := _c.mutation.CacheCreation1hTokens(); !ok {
		v := usagelog.DefaultCacheCreation1hTokens
		_c.mutation.SetCacheCreation1hTokens(v)
	}
	if _, ok := _c.mutation.InputCost(); !ok {
		v := usagelog.DefaultInputCost
		_c.mutation.SetInputCost(v)
	}
	if _, ok := _c.mutation.OutputCost(); !ok {
		v := usagelog.DefaultOutputCost
		_c.mutation.SetOutputCost(v)
	}
	if _, ok := _c.mutation.CacheCreationCost(); !ok {
		v := usagelog.DefaultCacheCreationCost
		_c.mutation.SetCacheCreationCost(v)
	}
	if _, ok := _c.mutation.CacheReadCost(); !ok {
		v := usagelog.DefaultCacheReadCost
		_c.mutation.SetCacheReadCost(v)
	}
	if _, ok := _c.mutation.TotalCost(); !ok {
		v := usagelog.DefaultTotalCost
		_c.mutation.SetTotalCost(v)
	}
	if _, ok := _c.mutation.ActualCost(); !ok {
		v := usagelog.DefaultActualCost
		_c.mutation.SetActualCost(v)
	}
	if _, ok := _c.mutation.RateMultiplier(); !ok {
		v := usagelog.DefaultRateMultiplier
		_c.mutation.SetRateMultiplier(v)
	}
	if _, ok := _c.mutation.BillingType(); !ok {
		v := usagelog.DefaultBillingType
		_c.mutation.SetBillingType(v)
	}
	if _, ok := _c.mutation.Stream(); !ok {
		v := usagelog.DefaultStream
		_c.mutation.SetStream(v)
	}
	if _, ok := _c.mutation.ImageCount(); !ok {
		v := usagelog.DefaultImageCount
		_c.mutation.SetImageCount(v)
	}
	if _, ok := _c.mutation.CreatedAt(); !ok {
		v := usagelog.DefaultCreatedAt()
		_c.mutation.SetCreatedAt(v)
	}
}

// check runs all checks and user-defined validators on the builder.
func (_c *UsageLogCreate) check() error {
	if _, ok := _c.mutation.UserID(); !ok {
		return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "UsageLog.user_id"`)}
	}
	if _, ok := _c.mutation.APIKeyID(); !ok {
		return &ValidationError{Name: "api_key_id", err: errors.New(`ent: missing required field "UsageLog.api_key_id"`)}
	}
	if _, ok := _c.mutation.AccountID(); !ok {
		return &ValidationError{Name: "account_id", err: errors.New(`ent: missing required field "UsageLog.account_id"`)}
	}
	if _, ok := _c.mutation.RequestID(); !ok {
		return &ValidationError{Name: "request_id", err: errors.New(`ent: missing required field "UsageLog.request_id"`)}
	}
	if v, ok := _c.mutation.RequestID(); ok {
		if err := usagelog.RequestIDValidator(v); err != nil {
			return &ValidationError{Name: "request_id", err: fmt.Errorf(`ent: validator failed for field "UsageLog.request_id": %w`, err)}
		}
	}
	if _, ok := _c.mutation.Model(); !ok {
		return &ValidationError{Name: "model", err: errors.New(`ent: missing required field "UsageLog.model"`)}
	}
	if v, ok := _c.mutation.Model(); ok {
		if err := usagelog.ModelValidator(v); err != nil {
			return &ValidationError{Name: "model", err: fmt.Errorf(`ent: validator failed for field "UsageLog.model": %w`, err)}
		}
	}
	if _, ok := _c.mutation.InputTokens(); !ok {
		return &ValidationError{Name: "input_tokens", err: errors.New(`ent: missing required field "UsageLog.input_tokens"`)}
	}
	if _, ok := _c.mutation.OutputTokens(); !ok {
		return &ValidationError{Name: "output_tokens", err: errors.New(`ent: missing required field "UsageLog.output_tokens"`)}
	}
	if _, ok := _c.mutation.CacheCreationTokens(); !ok {
		return &ValidationError{Name: "cache_creation_tokens", err: errors.New(`ent: missing required field "UsageLog.cache_creation_tokens"`)}
	}
	if _, ok := _c.mutation.CacheReadTokens(); !ok {
		return &ValidationError{Name: "cache_read_tokens", err: errors.New(`ent: missing required field "UsageLog.cache_read_tokens"`)}
	}
	if _, ok := _c.mutation.CacheCreation5mTokens(); !ok {
		return &ValidationError{Name: "cache_creation_5m_tokens", err: errors.New(`ent: missing required field "UsageLog.cache_creation_5m_tokens"`)}
	}
	if _, ok := _c.mutation.CacheCreation1hTokens(); !ok {
		return &ValidationError{Name: "cache_creation_1h_tokens", err: errors.New(`ent: missing required field "UsageLog.cache_creation_1h_tokens"`)}
	}
	if _, ok := _c.mutation.InputCost(); !ok {
		return &ValidationError{Name: "input_cost", err: errors.New(`ent: missing required field "UsageLog.input_cost"`)}
	}
	if _, ok := _c.mutation.OutputCost(); !ok {
		return &ValidationError{Name: "output_cost", err: errors.New(`ent: missing required field "UsageLog.output_cost"`)}
	}
	if _, ok := _c.mutation.CacheCreationCost(); !ok {
		return &ValidationError{Name: "cache_creation_cost", err: errors.New(`ent: missing required field "UsageLog.cache_creation_cost"`)}
	}
	if _, ok := _c.mutation.CacheReadCost(); !ok {
		return &ValidationError{Name: "cache_read_cost", err: errors.New(`ent: missing required field "UsageLog.cache_read_cost"`)}
	}
	if _, ok := _c.mutation.TotalCost(); !ok {
		return &ValidationError{Name: "total_cost", err: errors.New(`ent: missing required field "UsageLog.total_cost"`)}
	}
	if _, ok := _c.mutation.ActualCost(); !ok {
		return &ValidationError{Name: "actual_cost", err: errors.New(`ent: missing required field "UsageLog.actual_cost"`)}
	}
	if _, ok := _c.mutation.RateMultiplier(); !ok {
		return &ValidationError{Name: "rate_multiplier", err: errors.New(`ent: missing required field "UsageLog.rate_multiplier"`)}
	}
	if _, ok := _c.mutation.BillingType(); !ok {
		return &ValidationError{Name: "billing_type", err: errors.New(`ent: missing required field "UsageLog.billing_type"`)}
	}
	if _, ok := _c.mutation.Stream(); !ok {
		return &ValidationError{Name: "stream", err: errors.New(`ent: missing required field "UsageLog.stream"`)}
	}
	if _, ok := _c.mutation.ImageCount(); !ok {
		return &ValidationError{Name: "image_count", err: errors.New(`ent: missing required field "UsageLog.image_count"`)}
	}
	if v, ok := _c.mutation.ImageSize(); ok {
		if err := usagelog.ImageSizeValidator(v); err != nil {
			return &ValidationError{Name: "image_size", err: fmt.Errorf(`ent: validator failed for field "UsageLog.image_size": %w`, err)}
		}
	}
	if _, ok := _c.mutation.CreatedAt(); !ok {
		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UsageLog.created_at"`)}
	}
	if len(_c.mutation.UserIDs()) == 0 {
		return &ValidationError{Name: "user", err: errors.New(`ent: missing required edge "UsageLog.user"`)}
	}
	if len(_c.mutation.APIKeyIDs()) == 0 {
		return &ValidationError{Name: "api_key", err: errors.New(`ent: missing required edge "UsageLog.api_key"`)}
	}
	if len(_c.mutation.AccountIDs()) == 0 {
		return &ValidationError{Name: "account", err: errors.New(`ent: missing required edge "UsageLog.account"`)}
	}
	return nil
}

func (_c *UsageLogCreate) sqlSave(ctx context.Context) (*UsageLog, error) {
	if err := _c.check(); err != nil {
		return nil, err
	}
	_node, _spec := _c.createSpec()
	if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
		if sqlgraph.IsConstraintError(err) {
			err = &ConstraintError{msg: err.Error(), wrap: err}
		}
		return nil, err
	}
	id := _spec.ID.Value.(int64)
	_node.ID = int64(id)
	_c.mutation.id = &_node.ID
	_c.mutation.done = true
	return _node, nil
}

func (_c *UsageLogCreate) createSpec() (*UsageLog, *sqlgraph.CreateSpec) {
	var (
		_node = &UsageLog{config: _c.config}
		_spec = sqlgraph.NewCreateSpec(usagelog.Table, sqlgraph.NewFieldSpec(usagelog.FieldID, field.TypeInt64))
	)
	_spec.OnConflict = _c.conflict
	if value, ok := _c.mutation.RequestID(); ok {
		_spec.SetField(usagelog.FieldRequestID, field.TypeString, value)
		_node.RequestID = value
	}
	if value, ok := _c.mutation.Model(); ok {
		_spec.SetField(usagelog.FieldModel, field.TypeString, value)
		_node.Model = value
	}
	if value, ok := _c.mutation.InputTokens(); ok {
		_spec.SetField(usagelog.FieldInputTokens, field.TypeInt, value)
		_node.InputTokens = value
	}
	if value, ok := _c.mutation.OutputTokens(); ok {
		_spec.SetField(usagelog.FieldOutputTokens, field.TypeInt, value)
		_node.OutputTokens = value
	}
	if value, ok := _c.mutation.CacheCreationTokens(); ok {
		_spec.SetField(usagelog.FieldCacheCreationTokens, field.TypeInt, value)
		_node.CacheCreationTokens = value
	}
	if value, ok := _c.mutation.CacheReadTokens(); ok {
		_spec.SetField(usagelog.FieldCacheReadTokens, field.TypeInt, value)
		_node.CacheReadTokens = value
	}
	if value, ok := _c.mutation.CacheCreation5mTokens(); ok {
		_spec.SetField(usagelog.FieldCacheCreation5mTokens, field.TypeInt, value)
		_node.CacheCreation5mTokens = value
	}
	if value, ok := _c.mutation.CacheCreation1hTokens(); ok {
		_spec.SetField(usagelog.FieldCacheCreation1hTokens, field.TypeInt, value)
		_node.CacheCreation1hTokens = value
	}
	if value, ok := _c.mutation.InputCost(); ok {
		_spec.SetField(usagelog.FieldInputCost, field.TypeFloat64, value)
		_node.InputCost = value
	}
	if value, ok := _c.mutation.OutputCost(); ok {
		_spec.SetField(usagelog.FieldOutputCost, field.TypeFloat64, value)
		_node.OutputCost = value
	}
	if value, ok := _c.mutation.CacheCreationCost(); ok {
		_spec.SetField(usagelog.FieldCacheCreationCost, field.TypeFloat64, value)
		_node.CacheCreationCost = value
	}
	if value, ok := _c.mutation.CacheReadCost(); ok {
		_spec.SetField(usagelog.FieldCacheReadCost, field.TypeFloat64, value)
		_node.CacheReadCost = value
	}
	if value, ok := _c.mutation.TotalCost(); ok {
		_spec.SetField(usagelog.FieldTotalCost, field.TypeFloat64, value)
		_node.TotalCost = value
	}
	if value, ok := _c.mutation.ActualCost(); ok {
		_spec.SetField(usagelog.FieldActualCost, field.TypeFloat64, value)
		_node.ActualCost = value
	}
	if value, ok := _c.mutation.RateMultiplier(); ok {
		_spec.SetField(usagelog.FieldRateMultiplier, field.TypeFloat64, value)
		_node.RateMultiplier = value
	}
	if value, ok := _c.mutation.BillingType(); ok {
		_spec.SetField(usagelog.FieldBillingType, field.TypeInt8, value)
		_node.BillingType = value
	}
	if value, ok := _c.mutation.Stream(); ok {
		_spec.SetField(usagelog.FieldStream, field.TypeBool, value)
		_node.Stream = value
	}
	if value, ok := _c.mutation.DurationMs(); ok {
		_spec.SetField(usagelog.FieldDurationMs, field.TypeInt, value)
		_node.DurationMs = &value
	}
	if value, ok := _c.mutation.FirstTokenMs(); ok {
		_spec.SetField(usagelog.FieldFirstTokenMs, field.TypeInt, value)
		_node.FirstTokenMs = &value
	}
	if value, ok := _c.mutation.ImageCount(); ok {
		_spec.SetField(usagelog.FieldImageCount, field.TypeInt, value)
		_node.ImageCount = value
	}
	if value, ok := _c.mutation.ImageSize(); ok {
		_spec.SetField(usagelog.FieldImageSize, field.TypeString, value)
		_node.ImageSize = &value
	}
	if value, ok := _c.mutation.CreatedAt(); ok {
		_spec.SetField(usagelog.FieldCreatedAt, field.TypeTime, value)
		_node.CreatedAt = value
	}
	if nodes := _c.mutation.UserIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   usagelog.UserTable,
			Columns: []string{usagelog.UserColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.UserID = nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := _c.mutation.APIKeyIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   usagelog.APIKeyTable,
			Columns: []string{usagelog.APIKeyColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeInt64),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.APIKeyID = nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := _c.mutation.AccountIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   usagelog.AccountTable,
			Columns: []string{usagelog.AccountColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeInt64),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.AccountID = nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := _c.mutation.GroupIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   usagelog.GroupTable,
			Columns: []string{usagelog.GroupColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt64),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.GroupID = &nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := _c.mutation.SubscriptionIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   usagelog.SubscriptionTable,
			Columns: []string{usagelog.SubscriptionColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(usersubscription.FieldID, field.TypeInt64),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.SubscriptionID = &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.UsageLog.Create().
//		SetUserID(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.UsageLogUpsert) {
//			SetUserID(v+v).
//		}).
//		Exec(ctx)
func (_c *UsageLogCreate) OnConflict(opts ...sql.ConflictOption) *UsageLogUpsertOne {
	_c.conflict = opts
	return &UsageLogUpsertOne{
		create: _c,
	}
}

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

type (
	// UsageLogUpsertOne is the builder for "upsert"-ing
	//  one UsageLog node.
	UsageLogUpsertOne struct {
		create *UsageLogCreate
	}

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

// SetUserID sets the "user_id" field.
func (u *UsageLogUpsert) SetUserID(v int64) *UsageLogUpsert {
	u.Set(usagelog.FieldUserID, v)
	return u
}

// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateUserID() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldUserID)
	return u
}

// SetAPIKeyID sets the "api_key_id" field.
func (u *UsageLogUpsert) SetAPIKeyID(v int64) *UsageLogUpsert {
	u.Set(usagelog.FieldAPIKeyID, v)
	return u
}

// UpdateAPIKeyID sets the "api_key_id" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateAPIKeyID() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldAPIKeyID)
	return u
}

// SetAccountID sets the "account_id" field.
func (u *UsageLogUpsert) SetAccountID(v int64) *UsageLogUpsert {
	u.Set(usagelog.FieldAccountID, v)
	return u
}

// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateAccountID() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldAccountID)
	return u
}

// SetRequestID sets the "request_id" field.
func (u *UsageLogUpsert) SetRequestID(v string) *UsageLogUpsert {
	u.Set(usagelog.FieldRequestID, v)
	return u
}

// UpdateRequestID sets the "request_id" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateRequestID() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldRequestID)
	return u
}

// SetModel sets the "model" field.
func (u *UsageLogUpsert) SetModel(v string) *UsageLogUpsert {
	u.Set(usagelog.FieldModel, v)
	return u
}

// UpdateModel sets the "model" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateModel() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldModel)
	return u
}

// SetGroupID sets the "group_id" field.
func (u *UsageLogUpsert) SetGroupID(v int64) *UsageLogUpsert {
	u.Set(usagelog.FieldGroupID, v)
	return u
}

// UpdateGroupID sets the "group_id" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateGroupID() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldGroupID)
	return u
}

// ClearGroupID clears the value of the "group_id" field.
func (u *UsageLogUpsert) ClearGroupID() *UsageLogUpsert {
	u.SetNull(usagelog.FieldGroupID)
	return u
}

// SetSubscriptionID sets the "subscription_id" field.
func (u *UsageLogUpsert) SetSubscriptionID(v int64) *UsageLogUpsert {
	u.Set(usagelog.FieldSubscriptionID, v)
	return u
}

// UpdateSubscriptionID sets the "subscription_id" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateSubscriptionID() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldSubscriptionID)
	return u
}

// ClearSubscriptionID clears the value of the "subscription_id" field.
func (u *UsageLogUpsert) ClearSubscriptionID() *UsageLogUpsert {
	u.SetNull(usagelog.FieldSubscriptionID)
	return u
}

// SetInputTokens sets the "input_tokens" field.
func (u *UsageLogUpsert) SetInputTokens(v int) *UsageLogUpsert {
	u.Set(usagelog.FieldInputTokens, v)
	return u
}

// UpdateInputTokens sets the "input_tokens" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateInputTokens() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldInputTokens)
	return u
}

// AddInputTokens adds v to the "input_tokens" field.
func (u *UsageLogUpsert) AddInputTokens(v int) *UsageLogUpsert {
	u.Add(usagelog.FieldInputTokens, v)
	return u
}

// SetOutputTokens sets the "output_tokens" field.
func (u *UsageLogUpsert) SetOutputTokens(v int) *UsageLogUpsert {
	u.Set(usagelog.FieldOutputTokens, v)
	return u
}

// UpdateOutputTokens sets the "output_tokens" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateOutputTokens() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldOutputTokens)
	return u
}

// AddOutputTokens adds v to the "output_tokens" field.
func (u *UsageLogUpsert) AddOutputTokens(v int) *UsageLogUpsert {
	u.Add(usagelog.FieldOutputTokens, v)
	return u
}

// SetCacheCreationTokens sets the "cache_creation_tokens" field.
func (u *UsageLogUpsert) SetCacheCreationTokens(v int) *UsageLogUpsert {
	u.Set(usagelog.FieldCacheCreationTokens, v)
	return u
}

// UpdateCacheCreationTokens sets the "cache_creation_tokens" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateCacheCreationTokens() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldCacheCreationTokens)
	return u
}

// AddCacheCreationTokens adds v to the "cache_creation_tokens" field.
func (u *UsageLogUpsert) AddCacheCreationTokens(v int) *UsageLogUpsert {
	u.Add(usagelog.FieldCacheCreationTokens, v)
	return u
}

// SetCacheReadTokens sets the "cache_read_tokens" field.
func (u *UsageLogUpsert) SetCacheReadTokens(v int) *UsageLogUpsert {
	u.Set(usagelog.FieldCacheReadTokens, v)
	return u
}

// UpdateCacheReadTokens sets the "cache_read_tokens" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateCacheReadTokens() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldCacheReadTokens)
	return u
}

// AddCacheReadTokens adds v to the "cache_read_tokens" field.
func (u *UsageLogUpsert) AddCacheReadTokens(v int) *UsageLogUpsert {
	u.Add(usagelog.FieldCacheReadTokens, v)
	return u
}

// SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
func (u *UsageLogUpsert) SetCacheCreation5mTokens(v int) *UsageLogUpsert {
	u.Set(usagelog.FieldCacheCreation5mTokens, v)
	return u
}

// UpdateCacheCreation5mTokens sets the "cache_creation_5m_tokens" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateCacheCreation5mTokens() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldCacheCreation5mTokens)
	return u
}

// AddCacheCreation5mTokens adds v to the "cache_creation_5m_tokens" field.
func (u *UsageLogUpsert) AddCacheCreation5mTokens(v int) *UsageLogUpsert {
	u.Add(usagelog.FieldCacheCreation5mTokens, v)
	return u
}

// SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
func (u *UsageLogUpsert) SetCacheCreation1hTokens(v int) *UsageLogUpsert {
	u.Set(usagelog.FieldCacheCreation1hTokens, v)
	return u
}

// UpdateCacheCreation1hTokens sets the "cache_creation_1h_tokens" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateCacheCreation1hTokens() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldCacheCreation1hTokens)
	return u
}

// AddCacheCreation1hTokens adds v to the "cache_creation_1h_tokens" field.
func (u *UsageLogUpsert) AddCacheCreation1hTokens(v int) *UsageLogUpsert {
	u.Add(usagelog.FieldCacheCreation1hTokens, v)
	return u
}

// SetInputCost sets the "input_cost" field.
func (u *UsageLogUpsert) SetInputCost(v float64) *UsageLogUpsert {
	u.Set(usagelog.FieldInputCost, v)
	return u
}

// UpdateInputCost sets the "input_cost" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateInputCost() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldInputCost)
	return u
}

// AddInputCost adds v to the "input_cost" field.
func (u *UsageLogUpsert) AddInputCost(v float64) *UsageLogUpsert {
	u.Add(usagelog.FieldInputCost, v)
	return u
}

// SetOutputCost sets the "output_cost" field.
func (u *UsageLogUpsert) SetOutputCost(v float64) *UsageLogUpsert {
	u.Set(usagelog.FieldOutputCost, v)
	return u
}

// UpdateOutputCost sets the "output_cost" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateOutputCost() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldOutputCost)
	return u
}

// AddOutputCost adds v to the "output_cost" field.
func (u *UsageLogUpsert) AddOutputCost(v float64) *UsageLogUpsert {
	u.Add(usagelog.FieldOutputCost, v)
	return u
}

// SetCacheCreationCost sets the "cache_creation_cost" field.
func (u *UsageLogUpsert) SetCacheCreationCost(v float64) *UsageLogUpsert {
	u.Set(usagelog.FieldCacheCreationCost, v)
	return u
}

// UpdateCacheCreationCost sets the "cache_creation_cost" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateCacheCreationCost() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldCacheCreationCost)
	return u
}

// AddCacheCreationCost adds v to the "cache_creation_cost" field.
func (u *UsageLogUpsert) AddCacheCreationCost(v float64) *UsageLogUpsert {
	u.Add(usagelog.FieldCacheCreationCost, v)
	return u
}

// SetCacheReadCost sets the "cache_read_cost" field.
func (u *UsageLogUpsert) SetCacheReadCost(v float64) *UsageLogUpsert {
	u.Set(usagelog.FieldCacheReadCost, v)
	return u
}

// UpdateCacheReadCost sets the "cache_read_cost" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateCacheReadCost() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldCacheReadCost)
	return u
}

// AddCacheReadCost adds v to the "cache_read_cost" field.
func (u *UsageLogUpsert) AddCacheReadCost(v float64) *UsageLogUpsert {
	u.Add(usagelog.FieldCacheReadCost, v)
	return u
}

// SetTotalCost sets the "total_cost" field.
func (u *UsageLogUpsert) SetTotalCost(v float64) *UsageLogUpsert {
	u.Set(usagelog.FieldTotalCost, v)
	return u
}

// UpdateTotalCost sets the "total_cost" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateTotalCost() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldTotalCost)
	return u
}

// AddTotalCost adds v to the "total_cost" field.
func (u *UsageLogUpsert) AddTotalCost(v float64) *UsageLogUpsert {
	u.Add(usagelog.FieldTotalCost, v)
	return u
}

// SetActualCost sets the "actual_cost" field.
func (u *UsageLogUpsert) SetActualCost(v float64) *UsageLogUpsert {
	u.Set(usagelog.FieldActualCost, v)
	return u
}

// UpdateActualCost sets the "actual_cost" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateActualCost() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldActualCost)
	return u
}

// AddActualCost adds v to the "actual_cost" field.
func (u *UsageLogUpsert) AddActualCost(v float64) *UsageLogUpsert {
	u.Add(usagelog.FieldActualCost, v)
	return u
}

// SetRateMultiplier sets the "rate_multiplier" field.
func (u *UsageLogUpsert) SetRateMultiplier(v float64) *UsageLogUpsert {
	u.Set(usagelog.FieldRateMultiplier, v)
	return u
}

// UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateRateMultiplier() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldRateMultiplier)
	return u
}

// AddRateMultiplier adds v to the "rate_multiplier" field.
func (u *UsageLogUpsert) AddRateMultiplier(v float64) *UsageLogUpsert {
	u.Add(usagelog.FieldRateMultiplier, v)
	return u
}

// SetBillingType sets the "billing_type" field.
func (u *UsageLogUpsert) SetBillingType(v int8) *UsageLogUpsert {
	u.Set(usagelog.FieldBillingType, v)
	return u
}

// UpdateBillingType sets the "billing_type" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateBillingType() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldBillingType)
	return u
}

// AddBillingType adds v to the "billing_type" field.
func (u *UsageLogUpsert) AddBillingType(v int8) *UsageLogUpsert {
	u.Add(usagelog.FieldBillingType, v)
	return u
}

// SetStream sets the "stream" field.
func (u *UsageLogUpsert) SetStream(v bool) *UsageLogUpsert {
	u.Set(usagelog.FieldStream, v)
	return u
}

// UpdateStream sets the "stream" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateStream() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldStream)
	return u
}

// SetDurationMs sets the "duration_ms" field.
func (u *UsageLogUpsert) SetDurationMs(v int) *UsageLogUpsert {
	u.Set(usagelog.FieldDurationMs, v)
	return u
}

// UpdateDurationMs sets the "duration_ms" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateDurationMs() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldDurationMs)
	return u
}

// AddDurationMs adds v to the "duration_ms" field.
func (u *UsageLogUpsert) AddDurationMs(v int) *UsageLogUpsert {
	u.Add(usagelog.FieldDurationMs, v)
	return u
}

// ClearDurationMs clears the value of the "duration_ms" field.
func (u *UsageLogUpsert) ClearDurationMs() *UsageLogUpsert {
	u.SetNull(usagelog.FieldDurationMs)
	return u
}

// SetFirstTokenMs sets the "first_token_ms" field.
func (u *UsageLogUpsert) SetFirstTokenMs(v int) *UsageLogUpsert {
	u.Set(usagelog.FieldFirstTokenMs, v)
	return u
}

// UpdateFirstTokenMs sets the "first_token_ms" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateFirstTokenMs() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldFirstTokenMs)
	return u
}

// AddFirstTokenMs adds v to the "first_token_ms" field.
func (u *UsageLogUpsert) AddFirstTokenMs(v int) *UsageLogUpsert {
	u.Add(usagelog.FieldFirstTokenMs, v)
	return u
}

// ClearFirstTokenMs clears the value of the "first_token_ms" field.
func (u *UsageLogUpsert) ClearFirstTokenMs() *UsageLogUpsert {
	u.SetNull(usagelog.FieldFirstTokenMs)
	return u
}

// SetImageCount sets the "image_count" field.
func (u *UsageLogUpsert) SetImageCount(v int) *UsageLogUpsert {
	u.Set(usagelog.FieldImageCount, v)
	return u
}

// UpdateImageCount sets the "image_count" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateImageCount() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldImageCount)
	return u
}

// AddImageCount adds v to the "image_count" field.
func (u *UsageLogUpsert) AddImageCount(v int) *UsageLogUpsert {
	u.Add(usagelog.FieldImageCount, v)
	return u
}

// SetImageSize sets the "image_size" field.
func (u *UsageLogUpsert) SetImageSize(v string) *UsageLogUpsert {
	u.Set(usagelog.FieldImageSize, v)
	return u
}

// UpdateImageSize sets the "image_size" field to the value that was provided on create.
func (u *UsageLogUpsert) UpdateImageSize() *UsageLogUpsert {
	u.SetExcluded(usagelog.FieldImageSize)
	return u
}

// ClearImageSize clears the value of the "image_size" field.
func (u *UsageLogUpsert) ClearImageSize() *UsageLogUpsert {
	u.SetNull(usagelog.FieldImageSize)
	return u
}

// UpdateNewValues updates the mutable fields using the new values that were set on create.
// Using this option is equivalent to using:
//
//	client.UsageLog.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//		).
//		Exec(ctx)
func (u *UsageLogUpsertOne) UpdateNewValues() *UsageLogUpsertOne {
	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.CreatedAt(); exists {
			s.SetIgnore(usagelog.FieldCreatedAt)
		}
	}))
	return u
}

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

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

// SetUserID sets the "user_id" field.
func (u *UsageLogUpsertOne) SetUserID(v int64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetUserID(v)
	})
}

// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateUserID() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateUserID()
	})
}

// SetAPIKeyID sets the "api_key_id" field.
func (u *UsageLogUpsertOne) SetAPIKeyID(v int64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetAPIKeyID(v)
	})
}

// UpdateAPIKeyID sets the "api_key_id" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateAPIKeyID() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateAPIKeyID()
	})
}

// SetAccountID sets the "account_id" field.
func (u *UsageLogUpsertOne) SetAccountID(v int64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetAccountID(v)
	})
}

// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateAccountID() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateAccountID()
	})
}

// SetRequestID sets the "request_id" field.
func (u *UsageLogUpsertOne) SetRequestID(v string) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetRequestID(v)
	})
}

// UpdateRequestID sets the "request_id" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateRequestID() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateRequestID()
	})
}

// SetModel sets the "model" field.
func (u *UsageLogUpsertOne) SetModel(v string) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetModel(v)
	})
}

// UpdateModel sets the "model" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateModel() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateModel()
	})
}

// SetGroupID sets the "group_id" field.
func (u *UsageLogUpsertOne) SetGroupID(v int64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetGroupID(v)
	})
}

// UpdateGroupID sets the "group_id" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateGroupID() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateGroupID()
	})
}

// ClearGroupID clears the value of the "group_id" field.
func (u *UsageLogUpsertOne) ClearGroupID() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.ClearGroupID()
	})
}

// SetSubscriptionID sets the "subscription_id" field.
func (u *UsageLogUpsertOne) SetSubscriptionID(v int64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetSubscriptionID(v)
	})
}

// UpdateSubscriptionID sets the "subscription_id" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateSubscriptionID() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateSubscriptionID()
	})
}

// ClearSubscriptionID clears the value of the "subscription_id" field.
func (u *UsageLogUpsertOne) ClearSubscriptionID() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.ClearSubscriptionID()
	})
}

// SetInputTokens sets the "input_tokens" field.
func (u *UsageLogUpsertOne) SetInputTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetInputTokens(v)
	})
}

// AddInputTokens adds v to the "input_tokens" field.
func (u *UsageLogUpsertOne) AddInputTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddInputTokens(v)
	})
}

// UpdateInputTokens sets the "input_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateInputTokens() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateInputTokens()
	})
}

// SetOutputTokens sets the "output_tokens" field.
func (u *UsageLogUpsertOne) SetOutputTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetOutputTokens(v)
	})
}

// AddOutputTokens adds v to the "output_tokens" field.
func (u *UsageLogUpsertOne) AddOutputTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddOutputTokens(v)
	})
}

// UpdateOutputTokens sets the "output_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateOutputTokens() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateOutputTokens()
	})
}

// SetCacheCreationTokens sets the "cache_creation_tokens" field.
func (u *UsageLogUpsertOne) SetCacheCreationTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheCreationTokens(v)
	})
}

// AddCacheCreationTokens adds v to the "cache_creation_tokens" field.
func (u *UsageLogUpsertOne) AddCacheCreationTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheCreationTokens(v)
	})
}

// UpdateCacheCreationTokens sets the "cache_creation_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateCacheCreationTokens() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheCreationTokens()
	})
}

// SetCacheReadTokens sets the "cache_read_tokens" field.
func (u *UsageLogUpsertOne) SetCacheReadTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheReadTokens(v)
	})
}

// AddCacheReadTokens adds v to the "cache_read_tokens" field.
func (u *UsageLogUpsertOne) AddCacheReadTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheReadTokens(v)
	})
}

// UpdateCacheReadTokens sets the "cache_read_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateCacheReadTokens() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheReadTokens()
	})
}

// SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
func (u *UsageLogUpsertOne) SetCacheCreation5mTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheCreation5mTokens(v)
	})
}

// AddCacheCreation5mTokens adds v to the "cache_creation_5m_tokens" field.
func (u *UsageLogUpsertOne) AddCacheCreation5mTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheCreation5mTokens(v)
	})
}

// UpdateCacheCreation5mTokens sets the "cache_creation_5m_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateCacheCreation5mTokens() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheCreation5mTokens()
	})
}

// SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
func (u *UsageLogUpsertOne) SetCacheCreation1hTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheCreation1hTokens(v)
	})
}

// AddCacheCreation1hTokens adds v to the "cache_creation_1h_tokens" field.
func (u *UsageLogUpsertOne) AddCacheCreation1hTokens(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheCreation1hTokens(v)
	})
}

// UpdateCacheCreation1hTokens sets the "cache_creation_1h_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateCacheCreation1hTokens() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheCreation1hTokens()
	})
}

// SetInputCost sets the "input_cost" field.
func (u *UsageLogUpsertOne) SetInputCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetInputCost(v)
	})
}

// AddInputCost adds v to the "input_cost" field.
func (u *UsageLogUpsertOne) AddInputCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddInputCost(v)
	})
}

// UpdateInputCost sets the "input_cost" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateInputCost() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateInputCost()
	})
}

// SetOutputCost sets the "output_cost" field.
func (u *UsageLogUpsertOne) SetOutputCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetOutputCost(v)
	})
}

// AddOutputCost adds v to the "output_cost" field.
func (u *UsageLogUpsertOne) AddOutputCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddOutputCost(v)
	})
}

// UpdateOutputCost sets the "output_cost" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateOutputCost() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateOutputCost()
	})
}

// SetCacheCreationCost sets the "cache_creation_cost" field.
func (u *UsageLogUpsertOne) SetCacheCreationCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheCreationCost(v)
	})
}

// AddCacheCreationCost adds v to the "cache_creation_cost" field.
func (u *UsageLogUpsertOne) AddCacheCreationCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheCreationCost(v)
	})
}

// UpdateCacheCreationCost sets the "cache_creation_cost" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateCacheCreationCost() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheCreationCost()
	})
}

// SetCacheReadCost sets the "cache_read_cost" field.
func (u *UsageLogUpsertOne) SetCacheReadCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheReadCost(v)
	})
}

// AddCacheReadCost adds v to the "cache_read_cost" field.
func (u *UsageLogUpsertOne) AddCacheReadCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheReadCost(v)
	})
}

// UpdateCacheReadCost sets the "cache_read_cost" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateCacheReadCost() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheReadCost()
	})
}

// SetTotalCost sets the "total_cost" field.
func (u *UsageLogUpsertOne) SetTotalCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetTotalCost(v)
	})
}

// AddTotalCost adds v to the "total_cost" field.
func (u *UsageLogUpsertOne) AddTotalCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddTotalCost(v)
	})
}

// UpdateTotalCost sets the "total_cost" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateTotalCost() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateTotalCost()
	})
}

// SetActualCost sets the "actual_cost" field.
func (u *UsageLogUpsertOne) SetActualCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetActualCost(v)
	})
}

// AddActualCost adds v to the "actual_cost" field.
func (u *UsageLogUpsertOne) AddActualCost(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddActualCost(v)
	})
}

// UpdateActualCost sets the "actual_cost" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateActualCost() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateActualCost()
	})
}

// SetRateMultiplier sets the "rate_multiplier" field.
func (u *UsageLogUpsertOne) SetRateMultiplier(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetRateMultiplier(v)
	})
}

// AddRateMultiplier adds v to the "rate_multiplier" field.
func (u *UsageLogUpsertOne) AddRateMultiplier(v float64) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddRateMultiplier(v)
	})
}

// UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateRateMultiplier() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateRateMultiplier()
	})
}

// SetBillingType sets the "billing_type" field.
func (u *UsageLogUpsertOne) SetBillingType(v int8) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetBillingType(v)
	})
}

// AddBillingType adds v to the "billing_type" field.
func (u *UsageLogUpsertOne) AddBillingType(v int8) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddBillingType(v)
	})
}

// UpdateBillingType sets the "billing_type" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateBillingType() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateBillingType()
	})
}

// SetStream sets the "stream" field.
func (u *UsageLogUpsertOne) SetStream(v bool) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetStream(v)
	})
}

// UpdateStream sets the "stream" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateStream() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateStream()
	})
}

// SetDurationMs sets the "duration_ms" field.
func (u *UsageLogUpsertOne) SetDurationMs(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetDurationMs(v)
	})
}

// AddDurationMs adds v to the "duration_ms" field.
func (u *UsageLogUpsertOne) AddDurationMs(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddDurationMs(v)
	})
}

// UpdateDurationMs sets the "duration_ms" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateDurationMs() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateDurationMs()
	})
}

// ClearDurationMs clears the value of the "duration_ms" field.
func (u *UsageLogUpsertOne) ClearDurationMs() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.ClearDurationMs()
	})
}

// SetFirstTokenMs sets the "first_token_ms" field.
func (u *UsageLogUpsertOne) SetFirstTokenMs(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetFirstTokenMs(v)
	})
}

// AddFirstTokenMs adds v to the "first_token_ms" field.
func (u *UsageLogUpsertOne) AddFirstTokenMs(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddFirstTokenMs(v)
	})
}

// UpdateFirstTokenMs sets the "first_token_ms" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateFirstTokenMs() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateFirstTokenMs()
	})
}

// ClearFirstTokenMs clears the value of the "first_token_ms" field.
func (u *UsageLogUpsertOne) ClearFirstTokenMs() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.ClearFirstTokenMs()
	})
}

// SetImageCount sets the "image_count" field.
func (u *UsageLogUpsertOne) SetImageCount(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetImageCount(v)
	})
}

// AddImageCount adds v to the "image_count" field.
func (u *UsageLogUpsertOne) AddImageCount(v int) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddImageCount(v)
	})
}

// UpdateImageCount sets the "image_count" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateImageCount() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateImageCount()
	})
}

// SetImageSize sets the "image_size" field.
func (u *UsageLogUpsertOne) SetImageSize(v string) *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetImageSize(v)
	})
}

// UpdateImageSize sets the "image_size" field to the value that was provided on create.
func (u *UsageLogUpsertOne) UpdateImageSize() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateImageSize()
	})
}

// ClearImageSize clears the value of the "image_size" field.
func (u *UsageLogUpsertOne) ClearImageSize() *UsageLogUpsertOne {
	return u.Update(func(s *UsageLogUpsert) {
		s.ClearImageSize()
	})
}

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

// ExecX is like Exec, but panics if an error occurs.
func (u *UsageLogUpsertOne) 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 *UsageLogUpsertOne) ID(ctx context.Context) (id int64, err error) {
	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 *UsageLogUpsertOne) IDX(ctx context.Context) int64 {
	id, err := u.ID(ctx)
	if err != nil {
		panic(err)
	}
	return id
}

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

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

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

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

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

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.UsageLog.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.UsageLogUpsert) {
//			SetUserID(v+v).
//		}).
//		Exec(ctx)
func (_c *UsageLogCreateBulk) OnConflict(opts ...sql.ConflictOption) *UsageLogUpsertBulk {
	_c.conflict = opts
	return &UsageLogUpsertBulk{
		create: _c,
	}
}

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

// UsageLogUpsertBulk is the builder for "upsert"-ing
// a bulk of UsageLog nodes.
type UsageLogUpsertBulk struct {
	create *UsageLogCreateBulk
}

// UpdateNewValues updates the mutable fields using the new values that
// were set on create. Using this option is equivalent to using:
//
//	client.UsageLog.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//		).
//		Exec(ctx)
func (u *UsageLogUpsertBulk) UpdateNewValues() *UsageLogUpsertBulk {
	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.CreatedAt(); exists {
				s.SetIgnore(usagelog.FieldCreatedAt)
			}
		}
	}))
	return u
}

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

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

// SetUserID sets the "user_id" field.
func (u *UsageLogUpsertBulk) SetUserID(v int64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetUserID(v)
	})
}

// UpdateUserID sets the "user_id" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateUserID() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateUserID()
	})
}

// SetAPIKeyID sets the "api_key_id" field.
func (u *UsageLogUpsertBulk) SetAPIKeyID(v int64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetAPIKeyID(v)
	})
}

// UpdateAPIKeyID sets the "api_key_id" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateAPIKeyID() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateAPIKeyID()
	})
}

// SetAccountID sets the "account_id" field.
func (u *UsageLogUpsertBulk) SetAccountID(v int64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetAccountID(v)
	})
}

// UpdateAccountID sets the "account_id" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateAccountID() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateAccountID()
	})
}

// SetRequestID sets the "request_id" field.
func (u *UsageLogUpsertBulk) SetRequestID(v string) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetRequestID(v)
	})
}

// UpdateRequestID sets the "request_id" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateRequestID() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateRequestID()
	})
}

// SetModel sets the "model" field.
func (u *UsageLogUpsertBulk) SetModel(v string) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetModel(v)
	})
}

// UpdateModel sets the "model" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateModel() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateModel()
	})
}

// SetGroupID sets the "group_id" field.
func (u *UsageLogUpsertBulk) SetGroupID(v int64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetGroupID(v)
	})
}

// UpdateGroupID sets the "group_id" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateGroupID() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateGroupID()
	})
}

// ClearGroupID clears the value of the "group_id" field.
func (u *UsageLogUpsertBulk) ClearGroupID() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.ClearGroupID()
	})
}

// SetSubscriptionID sets the "subscription_id" field.
func (u *UsageLogUpsertBulk) SetSubscriptionID(v int64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetSubscriptionID(v)
	})
}

// UpdateSubscriptionID sets the "subscription_id" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateSubscriptionID() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateSubscriptionID()
	})
}

// ClearSubscriptionID clears the value of the "subscription_id" field.
func (u *UsageLogUpsertBulk) ClearSubscriptionID() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.ClearSubscriptionID()
	})
}

// SetInputTokens sets the "input_tokens" field.
func (u *UsageLogUpsertBulk) SetInputTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetInputTokens(v)
	})
}

// AddInputTokens adds v to the "input_tokens" field.
func (u *UsageLogUpsertBulk) AddInputTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddInputTokens(v)
	})
}

// UpdateInputTokens sets the "input_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateInputTokens() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateInputTokens()
	})
}

// SetOutputTokens sets the "output_tokens" field.
func (u *UsageLogUpsertBulk) SetOutputTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetOutputTokens(v)
	})
}

// AddOutputTokens adds v to the "output_tokens" field.
func (u *UsageLogUpsertBulk) AddOutputTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddOutputTokens(v)
	})
}

// UpdateOutputTokens sets the "output_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateOutputTokens() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateOutputTokens()
	})
}

// SetCacheCreationTokens sets the "cache_creation_tokens" field.
func (u *UsageLogUpsertBulk) SetCacheCreationTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheCreationTokens(v)
	})
}

// AddCacheCreationTokens adds v to the "cache_creation_tokens" field.
func (u *UsageLogUpsertBulk) AddCacheCreationTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheCreationTokens(v)
	})
}

// UpdateCacheCreationTokens sets the "cache_creation_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateCacheCreationTokens() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheCreationTokens()
	})
}

// SetCacheReadTokens sets the "cache_read_tokens" field.
func (u *UsageLogUpsertBulk) SetCacheReadTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheReadTokens(v)
	})
}

// AddCacheReadTokens adds v to the "cache_read_tokens" field.
func (u *UsageLogUpsertBulk) AddCacheReadTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheReadTokens(v)
	})
}

// UpdateCacheReadTokens sets the "cache_read_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateCacheReadTokens() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheReadTokens()
	})
}

// SetCacheCreation5mTokens sets the "cache_creation_5m_tokens" field.
func (u *UsageLogUpsertBulk) SetCacheCreation5mTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheCreation5mTokens(v)
	})
}

// AddCacheCreation5mTokens adds v to the "cache_creation_5m_tokens" field.
func (u *UsageLogUpsertBulk) AddCacheCreation5mTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheCreation5mTokens(v)
	})
}

// UpdateCacheCreation5mTokens sets the "cache_creation_5m_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateCacheCreation5mTokens() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheCreation5mTokens()
	})
}

// SetCacheCreation1hTokens sets the "cache_creation_1h_tokens" field.
func (u *UsageLogUpsertBulk) SetCacheCreation1hTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheCreation1hTokens(v)
	})
}

// AddCacheCreation1hTokens adds v to the "cache_creation_1h_tokens" field.
func (u *UsageLogUpsertBulk) AddCacheCreation1hTokens(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheCreation1hTokens(v)
	})
}

// UpdateCacheCreation1hTokens sets the "cache_creation_1h_tokens" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateCacheCreation1hTokens() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheCreation1hTokens()
	})
}

// SetInputCost sets the "input_cost" field.
func (u *UsageLogUpsertBulk) SetInputCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetInputCost(v)
	})
}

// AddInputCost adds v to the "input_cost" field.
func (u *UsageLogUpsertBulk) AddInputCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddInputCost(v)
	})
}

// UpdateInputCost sets the "input_cost" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateInputCost() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateInputCost()
	})
}

// SetOutputCost sets the "output_cost" field.
func (u *UsageLogUpsertBulk) SetOutputCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetOutputCost(v)
	})
}

// AddOutputCost adds v to the "output_cost" field.
func (u *UsageLogUpsertBulk) AddOutputCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddOutputCost(v)
	})
}

// UpdateOutputCost sets the "output_cost" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateOutputCost() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateOutputCost()
	})
}

// SetCacheCreationCost sets the "cache_creation_cost" field.
func (u *UsageLogUpsertBulk) SetCacheCreationCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheCreationCost(v)
	})
}

// AddCacheCreationCost adds v to the "cache_creation_cost" field.
func (u *UsageLogUpsertBulk) AddCacheCreationCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheCreationCost(v)
	})
}

// UpdateCacheCreationCost sets the "cache_creation_cost" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateCacheCreationCost() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheCreationCost()
	})
}

// SetCacheReadCost sets the "cache_read_cost" field.
func (u *UsageLogUpsertBulk) SetCacheReadCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetCacheReadCost(v)
	})
}

// AddCacheReadCost adds v to the "cache_read_cost" field.
func (u *UsageLogUpsertBulk) AddCacheReadCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddCacheReadCost(v)
	})
}

// UpdateCacheReadCost sets the "cache_read_cost" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateCacheReadCost() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateCacheReadCost()
	})
}

// SetTotalCost sets the "total_cost" field.
func (u *UsageLogUpsertBulk) SetTotalCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetTotalCost(v)
	})
}

// AddTotalCost adds v to the "total_cost" field.
func (u *UsageLogUpsertBulk) AddTotalCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddTotalCost(v)
	})
}

// UpdateTotalCost sets the "total_cost" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateTotalCost() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateTotalCost()
	})
}

// SetActualCost sets the "actual_cost" field.
func (u *UsageLogUpsertBulk) SetActualCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetActualCost(v)
	})
}

// AddActualCost adds v to the "actual_cost" field.
func (u *UsageLogUpsertBulk) AddActualCost(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddActualCost(v)
	})
}

// UpdateActualCost sets the "actual_cost" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateActualCost() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateActualCost()
	})
}

// SetRateMultiplier sets the "rate_multiplier" field.
func (u *UsageLogUpsertBulk) SetRateMultiplier(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetRateMultiplier(v)
	})
}

// AddRateMultiplier adds v to the "rate_multiplier" field.
func (u *UsageLogUpsertBulk) AddRateMultiplier(v float64) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddRateMultiplier(v)
	})
}

// UpdateRateMultiplier sets the "rate_multiplier" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateRateMultiplier() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateRateMultiplier()
	})
}

// SetBillingType sets the "billing_type" field.
func (u *UsageLogUpsertBulk) SetBillingType(v int8) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetBillingType(v)
	})
}

// AddBillingType adds v to the "billing_type" field.
func (u *UsageLogUpsertBulk) AddBillingType(v int8) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddBillingType(v)
	})
}

// UpdateBillingType sets the "billing_type" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateBillingType() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateBillingType()
	})
}

// SetStream sets the "stream" field.
func (u *UsageLogUpsertBulk) SetStream(v bool) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetStream(v)
	})
}

// UpdateStream sets the "stream" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateStream() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateStream()
	})
}

// SetDurationMs sets the "duration_ms" field.
func (u *UsageLogUpsertBulk) SetDurationMs(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetDurationMs(v)
	})
}

// AddDurationMs adds v to the "duration_ms" field.
func (u *UsageLogUpsertBulk) AddDurationMs(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddDurationMs(v)
	})
}

// UpdateDurationMs sets the "duration_ms" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateDurationMs() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateDurationMs()
	})
}

// ClearDurationMs clears the value of the "duration_ms" field.
func (u *UsageLogUpsertBulk) ClearDurationMs() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.ClearDurationMs()
	})
}

// SetFirstTokenMs sets the "first_token_ms" field.
func (u *UsageLogUpsertBulk) SetFirstTokenMs(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetFirstTokenMs(v)
	})
}

// AddFirstTokenMs adds v to the "first_token_ms" field.
func (u *UsageLogUpsertBulk) AddFirstTokenMs(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddFirstTokenMs(v)
	})
}

// UpdateFirstTokenMs sets the "first_token_ms" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateFirstTokenMs() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateFirstTokenMs()
	})
}

// ClearFirstTokenMs clears the value of the "first_token_ms" field.
func (u *UsageLogUpsertBulk) ClearFirstTokenMs() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.ClearFirstTokenMs()
	})
}

// SetImageCount sets the "image_count" field.
func (u *UsageLogUpsertBulk) SetImageCount(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetImageCount(v)
	})
}

// AddImageCount adds v to the "image_count" field.
func (u *UsageLogUpsertBulk) AddImageCount(v int) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.AddImageCount(v)
	})
}

// UpdateImageCount sets the "image_count" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateImageCount() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateImageCount()
	})
}

// SetImageSize sets the "image_size" field.
func (u *UsageLogUpsertBulk) SetImageSize(v string) *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.SetImageSize(v)
	})
}

// UpdateImageSize sets the "image_size" field to the value that was provided on create.
func (u *UsageLogUpsertBulk) UpdateImageSize() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.UpdateImageSize()
	})
}

// ClearImageSize clears the value of the "image_size" field.
func (u *UsageLogUpsertBulk) ClearImageSize() *UsageLogUpsertBulk {
	return u.Update(func(s *UsageLogUpsert) {
		s.ClearImageSize()
	})
}

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

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