// 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/cloudreve/Cloudreve/v4/ent/davaccount"
	"github.com/cloudreve/Cloudreve/v4/ent/entity"
	"github.com/cloudreve/Cloudreve/v4/ent/file"
	"github.com/cloudreve/Cloudreve/v4/ent/group"
	"github.com/cloudreve/Cloudreve/v4/ent/passkey"
	"github.com/cloudreve/Cloudreve/v4/ent/share"
	"github.com/cloudreve/Cloudreve/v4/ent/task"
	"github.com/cloudreve/Cloudreve/v4/ent/user"
	"github.com/cloudreve/Cloudreve/v4/inventory/types"
)

// UserCreate is the builder for creating a User entity.
type UserCreate struct {
	config
	mutation *UserMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetCreatedAt sets the "created_at" field.
func (uc *UserCreate) SetCreatedAt(t time.Time) *UserCreate {
	uc.mutation.SetCreatedAt(t)
	return uc
}

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

// SetUpdatedAt sets the "updated_at" field.
func (uc *UserCreate) SetUpdatedAt(t time.Time) *UserCreate {
	uc.mutation.SetUpdatedAt(t)
	return uc
}

// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
func (uc *UserCreate) SetNillableUpdatedAt(t *time.Time) *UserCreate {
	if t != nil {
		uc.SetUpdatedAt(*t)
	}
	return uc
}

// SetDeletedAt sets the "deleted_at" field.
func (uc *UserCreate) SetDeletedAt(t time.Time) *UserCreate {
	uc.mutation.SetDeletedAt(t)
	return uc
}

// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
func (uc *UserCreate) SetNillableDeletedAt(t *time.Time) *UserCreate {
	if t != nil {
		uc.SetDeletedAt(*t)
	}
	return uc
}

// SetEmail sets the "email" field.
func (uc *UserCreate) SetEmail(s string) *UserCreate {
	uc.mutation.SetEmail(s)
	return uc
}

// SetNick sets the "nick" field.
func (uc *UserCreate) SetNick(s string) *UserCreate {
	uc.mutation.SetNick(s)
	return uc
}

// SetPassword sets the "password" field.
func (uc *UserCreate) SetPassword(s string) *UserCreate {
	uc.mutation.SetPassword(s)
	return uc
}

// SetNillablePassword sets the "password" field if the given value is not nil.
func (uc *UserCreate) SetNillablePassword(s *string) *UserCreate {
	if s != nil {
		uc.SetPassword(*s)
	}
	return uc
}

// SetStatus sets the "status" field.
func (uc *UserCreate) SetStatus(u user.Status) *UserCreate {
	uc.mutation.SetStatus(u)
	return uc
}

// SetNillableStatus sets the "status" field if the given value is not nil.
func (uc *UserCreate) SetNillableStatus(u *user.Status) *UserCreate {
	if u != nil {
		uc.SetStatus(*u)
	}
	return uc
}

// SetStorage sets the "storage" field.
func (uc *UserCreate) SetStorage(i int64) *UserCreate {
	uc.mutation.SetStorage(i)
	return uc
}

// SetNillableStorage sets the "storage" field if the given value is not nil.
func (uc *UserCreate) SetNillableStorage(i *int64) *UserCreate {
	if i != nil {
		uc.SetStorage(*i)
	}
	return uc
}

// SetTwoFactorSecret sets the "two_factor_secret" field.
func (uc *UserCreate) SetTwoFactorSecret(s string) *UserCreate {
	uc.mutation.SetTwoFactorSecret(s)
	return uc
}

// SetNillableTwoFactorSecret sets the "two_factor_secret" field if the given value is not nil.
func (uc *UserCreate) SetNillableTwoFactorSecret(s *string) *UserCreate {
	if s != nil {
		uc.SetTwoFactorSecret(*s)
	}
	return uc
}

// SetAvatar sets the "avatar" field.
func (uc *UserCreate) SetAvatar(s string) *UserCreate {
	uc.mutation.SetAvatar(s)
	return uc
}

// SetNillableAvatar sets the "avatar" field if the given value is not nil.
func (uc *UserCreate) SetNillableAvatar(s *string) *UserCreate {
	if s != nil {
		uc.SetAvatar(*s)
	}
	return uc
}

// SetSettings sets the "settings" field.
func (uc *UserCreate) SetSettings(ts *types.UserSetting) *UserCreate {
	uc.mutation.SetSettings(ts)
	return uc
}

// SetGroupUsers sets the "group_users" field.
func (uc *UserCreate) SetGroupUsers(i int) *UserCreate {
	uc.mutation.SetGroupUsers(i)
	return uc
}

// SetGroupID sets the "group" edge to the Group entity by ID.
func (uc *UserCreate) SetGroupID(id int) *UserCreate {
	uc.mutation.SetGroupID(id)
	return uc
}

// SetGroup sets the "group" edge to the Group entity.
func (uc *UserCreate) SetGroup(g *Group) *UserCreate {
	return uc.SetGroupID(g.ID)
}

// AddFileIDs adds the "files" edge to the File entity by IDs.
func (uc *UserCreate) AddFileIDs(ids ...int) *UserCreate {
	uc.mutation.AddFileIDs(ids...)
	return uc
}

// AddFiles adds the "files" edges to the File entity.
func (uc *UserCreate) AddFiles(f ...*File) *UserCreate {
	ids := make([]int, len(f))
	for i := range f {
		ids[i] = f[i].ID
	}
	return uc.AddFileIDs(ids...)
}

// AddDavAccountIDs adds the "dav_accounts" edge to the DavAccount entity by IDs.
func (uc *UserCreate) AddDavAccountIDs(ids ...int) *UserCreate {
	uc.mutation.AddDavAccountIDs(ids...)
	return uc
}

// AddDavAccounts adds the "dav_accounts" edges to the DavAccount entity.
func (uc *UserCreate) AddDavAccounts(d ...*DavAccount) *UserCreate {
	ids := make([]int, len(d))
	for i := range d {
		ids[i] = d[i].ID
	}
	return uc.AddDavAccountIDs(ids...)
}

// AddShareIDs adds the "shares" edge to the Share entity by IDs.
func (uc *UserCreate) AddShareIDs(ids ...int) *UserCreate {
	uc.mutation.AddShareIDs(ids...)
	return uc
}

// AddShares adds the "shares" edges to the Share entity.
func (uc *UserCreate) AddShares(s ...*Share) *UserCreate {
	ids := make([]int, len(s))
	for i := range s {
		ids[i] = s[i].ID
	}
	return uc.AddShareIDs(ids...)
}

// AddPasskeyIDs adds the "passkey" edge to the Passkey entity by IDs.
func (uc *UserCreate) AddPasskeyIDs(ids ...int) *UserCreate {
	uc.mutation.AddPasskeyIDs(ids...)
	return uc
}

// AddPasskey adds the "passkey" edges to the Passkey entity.
func (uc *UserCreate) AddPasskey(p ...*Passkey) *UserCreate {
	ids := make([]int, len(p))
	for i := range p {
		ids[i] = p[i].ID
	}
	return uc.AddPasskeyIDs(ids...)
}

// AddTaskIDs adds the "tasks" edge to the Task entity by IDs.
func (uc *UserCreate) AddTaskIDs(ids ...int) *UserCreate {
	uc.mutation.AddTaskIDs(ids...)
	return uc
}

// AddTasks adds the "tasks" edges to the Task entity.
func (uc *UserCreate) AddTasks(t ...*Task) *UserCreate {
	ids := make([]int, len(t))
	for i := range t {
		ids[i] = t[i].ID
	}
	return uc.AddTaskIDs(ids...)
}

// AddEntityIDs adds the "entities" edge to the Entity entity by IDs.
func (uc *UserCreate) AddEntityIDs(ids ...int) *UserCreate {
	uc.mutation.AddEntityIDs(ids...)
	return uc
}

// AddEntities adds the "entities" edges to the Entity entity.
func (uc *UserCreate) AddEntities(e ...*Entity) *UserCreate {
	ids := make([]int, len(e))
	for i := range e {
		ids[i] = e[i].ID
	}
	return uc.AddEntityIDs(ids...)
}

// Mutation returns the UserMutation object of the builder.
func (uc *UserCreate) Mutation() *UserMutation {
	return uc.mutation
}

// Save creates the User in the database.
func (uc *UserCreate) Save(ctx context.Context) (*User, error) {
	if err := uc.defaults(); err != nil {
		return nil, err
	}
	return withHooks(ctx, uc.sqlSave, uc.mutation, uc.hooks)
}

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

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

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

// defaults sets the default values of the builder before save.
func (uc *UserCreate) defaults() error {
	if _, ok := uc.mutation.CreatedAt(); !ok {
		if user.DefaultCreatedAt == nil {
			return fmt.Errorf("ent: uninitialized user.DefaultCreatedAt (forgotten import ent/runtime?)")
		}
		v := user.DefaultCreatedAt()
		uc.mutation.SetCreatedAt(v)
	}
	if _, ok := uc.mutation.UpdatedAt(); !ok {
		if user.DefaultUpdatedAt == nil {
			return fmt.Errorf("ent: uninitialized user.DefaultUpdatedAt (forgotten import ent/runtime?)")
		}
		v := user.DefaultUpdatedAt()
		uc.mutation.SetUpdatedAt(v)
	}
	if _, ok := uc.mutation.Status(); !ok {
		v := user.DefaultStatus
		uc.mutation.SetStatus(v)
	}
	if _, ok := uc.mutation.Storage(); !ok {
		v := user.DefaultStorage
		uc.mutation.SetStorage(v)
	}
	if _, ok := uc.mutation.Settings(); !ok {
		v := user.DefaultSettings
		uc.mutation.SetSettings(v)
	}
	return nil
}

// check runs all checks and user-defined validators on the builder.
func (uc *UserCreate) check() error {
	if _, ok := uc.mutation.CreatedAt(); !ok {
		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "User.created_at"`)}
	}
	if _, ok := uc.mutation.UpdatedAt(); !ok {
		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "User.updated_at"`)}
	}
	if _, ok := uc.mutation.Email(); !ok {
		return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "User.email"`)}
	}
	if v, ok := uc.mutation.Email(); ok {
		if err := user.EmailValidator(v); err != nil {
			return &ValidationError{Name: "email", err: fmt.Errorf(`ent: validator failed for field "User.email": %w`, err)}
		}
	}
	if _, ok := uc.mutation.Nick(); !ok {
		return &ValidationError{Name: "nick", err: errors.New(`ent: missing required field "User.nick"`)}
	}
	if v, ok := uc.mutation.Nick(); ok {
		if err := user.NickValidator(v); err != nil {
			return &ValidationError{Name: "nick", err: fmt.Errorf(`ent: validator failed for field "User.nick": %w`, err)}
		}
	}
	if _, ok := uc.mutation.Status(); !ok {
		return &ValidationError{Name: "status", err: errors.New(`ent: missing required field "User.status"`)}
	}
	if v, ok := uc.mutation.Status(); ok {
		if err := user.StatusValidator(v); err != nil {
			return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "User.status": %w`, err)}
		}
	}
	if _, ok := uc.mutation.Storage(); !ok {
		return &ValidationError{Name: "storage", err: errors.New(`ent: missing required field "User.storage"`)}
	}
	if _, ok := uc.mutation.GroupUsers(); !ok {
		return &ValidationError{Name: "group_users", err: errors.New(`ent: missing required field "User.group_users"`)}
	}
	if _, ok := uc.mutation.GroupID(); !ok {
		return &ValidationError{Name: "group", err: errors.New(`ent: missing required edge "User.group"`)}
	}
	return nil
}

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

func (uc *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
	var (
		_node = &User{config: uc.config}
		_spec = sqlgraph.NewCreateSpec(user.Table, sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt))
	)

	if id, ok := uc.mutation.ID(); ok {
		_node.ID = id
		id64 := int64(id)
		_spec.ID.Value = id64
	}

	_spec.OnConflict = uc.conflict
	if value, ok := uc.mutation.CreatedAt(); ok {
		_spec.SetField(user.FieldCreatedAt, field.TypeTime, value)
		_node.CreatedAt = value
	}
	if value, ok := uc.mutation.UpdatedAt(); ok {
		_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
		_node.UpdatedAt = value
	}
	if value, ok := uc.mutation.DeletedAt(); ok {
		_spec.SetField(user.FieldDeletedAt, field.TypeTime, value)
		_node.DeletedAt = &value
	}
	if value, ok := uc.mutation.Email(); ok {
		_spec.SetField(user.FieldEmail, field.TypeString, value)
		_node.Email = value
	}
	if value, ok := uc.mutation.Nick(); ok {
		_spec.SetField(user.FieldNick, field.TypeString, value)
		_node.Nick = value
	}
	if value, ok := uc.mutation.Password(); ok {
		_spec.SetField(user.FieldPassword, field.TypeString, value)
		_node.Password = value
	}
	if value, ok := uc.mutation.Status(); ok {
		_spec.SetField(user.FieldStatus, field.TypeEnum, value)
		_node.Status = value
	}
	if value, ok := uc.mutation.Storage(); ok {
		_spec.SetField(user.FieldStorage, field.TypeInt64, value)
		_node.Storage = value
	}
	if value, ok := uc.mutation.TwoFactorSecret(); ok {
		_spec.SetField(user.FieldTwoFactorSecret, field.TypeString, value)
		_node.TwoFactorSecret = value
	}
	if value, ok := uc.mutation.Avatar(); ok {
		_spec.SetField(user.FieldAvatar, field.TypeString, value)
		_node.Avatar = value
	}
	if value, ok := uc.mutation.Settings(); ok {
		_spec.SetField(user.FieldSettings, field.TypeJSON, value)
		_node.Settings = value
	}
	if nodes := uc.mutation.GroupIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.M2O,
			Inverse: true,
			Table:   user.GroupTable,
			Columns: []string{user.GroupColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_node.GroupUsers = nodes[0]
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := uc.mutation.FilesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   user.FilesTable,
			Columns: []string{user.FilesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(file.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := uc.mutation.DavAccountsIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   user.DavAccountsTable,
			Columns: []string{user.DavAccountsColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(davaccount.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := uc.mutation.SharesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   user.SharesTable,
			Columns: []string{user.SharesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(share.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := uc.mutation.PasskeyIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   user.PasskeyTable,
			Columns: []string{user.PasskeyColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(passkey.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := uc.mutation.TasksIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   user.TasksTable,
			Columns: []string{user.TasksColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(task.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	if nodes := uc.mutation.EntitiesIDs(); len(nodes) > 0 {
		edge := &sqlgraph.EdgeSpec{
			Rel:     sqlgraph.O2M,
			Inverse: false,
			Table:   user.EntitiesTable,
			Columns: []string{user.EntitiesColumn},
			Bidi:    false,
			Target: &sqlgraph.EdgeTarget{
				IDSpec: sqlgraph.NewFieldSpec(entity.FieldID, field.TypeInt),
			},
		}
		for _, k := range nodes {
			edge.Target.Nodes = append(edge.Target.Nodes, k)
		}
		_spec.Edges = append(_spec.Edges, edge)
	}
	return _node, _spec
}

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.User.Create().
//		SetCreatedAt(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.UserUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
func (uc *UserCreate) OnConflict(opts ...sql.ConflictOption) *UserUpsertOne {
	uc.conflict = opts
	return &UserUpsertOne{
		create: uc,
	}
}

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

type (
	// UserUpsertOne is the builder for "upsert"-ing
	//  one User node.
	UserUpsertOne struct {
		create *UserCreate
	}

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

// SetUpdatedAt sets the "updated_at" field.
func (u *UserUpsert) SetUpdatedAt(v time.Time) *UserUpsert {
	u.Set(user.FieldUpdatedAt, v)
	return u
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *UserUpsert) UpdateUpdatedAt() *UserUpsert {
	u.SetExcluded(user.FieldUpdatedAt)
	return u
}

// SetDeletedAt sets the "deleted_at" field.
func (u *UserUpsert) SetDeletedAt(v time.Time) *UserUpsert {
	u.Set(user.FieldDeletedAt, v)
	return u
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *UserUpsert) UpdateDeletedAt() *UserUpsert {
	u.SetExcluded(user.FieldDeletedAt)
	return u
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *UserUpsert) ClearDeletedAt() *UserUpsert {
	u.SetNull(user.FieldDeletedAt)
	return u
}

// SetEmail sets the "email" field.
func (u *UserUpsert) SetEmail(v string) *UserUpsert {
	u.Set(user.FieldEmail, v)
	return u
}

// UpdateEmail sets the "email" field to the value that was provided on create.
func (u *UserUpsert) UpdateEmail() *UserUpsert {
	u.SetExcluded(user.FieldEmail)
	return u
}

// SetNick sets the "nick" field.
func (u *UserUpsert) SetNick(v string) *UserUpsert {
	u.Set(user.FieldNick, v)
	return u
}

// UpdateNick sets the "nick" field to the value that was provided on create.
func (u *UserUpsert) UpdateNick() *UserUpsert {
	u.SetExcluded(user.FieldNick)
	return u
}

// SetPassword sets the "password" field.
func (u *UserUpsert) SetPassword(v string) *UserUpsert {
	u.Set(user.FieldPassword, v)
	return u
}

// UpdatePassword sets the "password" field to the value that was provided on create.
func (u *UserUpsert) UpdatePassword() *UserUpsert {
	u.SetExcluded(user.FieldPassword)
	return u
}

// ClearPassword clears the value of the "password" field.
func (u *UserUpsert) ClearPassword() *UserUpsert {
	u.SetNull(user.FieldPassword)
	return u
}

// SetStatus sets the "status" field.
func (u *UserUpsert) SetStatus(v user.Status) *UserUpsert {
	u.Set(user.FieldStatus, v)
	return u
}

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

// SetStorage sets the "storage" field.
func (u *UserUpsert) SetStorage(v int64) *UserUpsert {
	u.Set(user.FieldStorage, v)
	return u
}

// UpdateStorage sets the "storage" field to the value that was provided on create.
func (u *UserUpsert) UpdateStorage() *UserUpsert {
	u.SetExcluded(user.FieldStorage)
	return u
}

// AddStorage adds v to the "storage" field.
func (u *UserUpsert) AddStorage(v int64) *UserUpsert {
	u.Add(user.FieldStorage, v)
	return u
}

// SetTwoFactorSecret sets the "two_factor_secret" field.
func (u *UserUpsert) SetTwoFactorSecret(v string) *UserUpsert {
	u.Set(user.FieldTwoFactorSecret, v)
	return u
}

// UpdateTwoFactorSecret sets the "two_factor_secret" field to the value that was provided on create.
func (u *UserUpsert) UpdateTwoFactorSecret() *UserUpsert {
	u.SetExcluded(user.FieldTwoFactorSecret)
	return u
}

// ClearTwoFactorSecret clears the value of the "two_factor_secret" field.
func (u *UserUpsert) ClearTwoFactorSecret() *UserUpsert {
	u.SetNull(user.FieldTwoFactorSecret)
	return u
}

// SetAvatar sets the "avatar" field.
func (u *UserUpsert) SetAvatar(v string) *UserUpsert {
	u.Set(user.FieldAvatar, v)
	return u
}

// UpdateAvatar sets the "avatar" field to the value that was provided on create.
func (u *UserUpsert) UpdateAvatar() *UserUpsert {
	u.SetExcluded(user.FieldAvatar)
	return u
}

// ClearAvatar clears the value of the "avatar" field.
func (u *UserUpsert) ClearAvatar() *UserUpsert {
	u.SetNull(user.FieldAvatar)
	return u
}

// SetSettings sets the "settings" field.
func (u *UserUpsert) SetSettings(v *types.UserSetting) *UserUpsert {
	u.Set(user.FieldSettings, v)
	return u
}

// UpdateSettings sets the "settings" field to the value that was provided on create.
func (u *UserUpsert) UpdateSettings() *UserUpsert {
	u.SetExcluded(user.FieldSettings)
	return u
}

// ClearSettings clears the value of the "settings" field.
func (u *UserUpsert) ClearSettings() *UserUpsert {
	u.SetNull(user.FieldSettings)
	return u
}

// SetGroupUsers sets the "group_users" field.
func (u *UserUpsert) SetGroupUsers(v int) *UserUpsert {
	u.Set(user.FieldGroupUsers, v)
	return u
}

// UpdateGroupUsers sets the "group_users" field to the value that was provided on create.
func (u *UserUpsert) UpdateGroupUsers() *UserUpsert {
	u.SetExcluded(user.FieldGroupUsers)
	return u
}

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

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

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

// SetUpdatedAt sets the "updated_at" field.
func (u *UserUpsertOne) SetUpdatedAt(v time.Time) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *UserUpsertOne) UpdateUpdatedAt() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.UpdateUpdatedAt()
	})
}

// SetDeletedAt sets the "deleted_at" field.
func (u *UserUpsertOne) SetDeletedAt(v time.Time) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.SetDeletedAt(v)
	})
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *UserUpsertOne) UpdateDeletedAt() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.UpdateDeletedAt()
	})
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *UserUpsertOne) ClearDeletedAt() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.ClearDeletedAt()
	})
}

// SetEmail sets the "email" field.
func (u *UserUpsertOne) SetEmail(v string) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.SetEmail(v)
	})
}

// UpdateEmail sets the "email" field to the value that was provided on create.
func (u *UserUpsertOne) UpdateEmail() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.UpdateEmail()
	})
}

// SetNick sets the "nick" field.
func (u *UserUpsertOne) SetNick(v string) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.SetNick(v)
	})
}

// UpdateNick sets the "nick" field to the value that was provided on create.
func (u *UserUpsertOne) UpdateNick() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.UpdateNick()
	})
}

// SetPassword sets the "password" field.
func (u *UserUpsertOne) SetPassword(v string) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.SetPassword(v)
	})
}

// UpdatePassword sets the "password" field to the value that was provided on create.
func (u *UserUpsertOne) UpdatePassword() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.UpdatePassword()
	})
}

// ClearPassword clears the value of the "password" field.
func (u *UserUpsertOne) ClearPassword() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.ClearPassword()
	})
}

// SetStatus sets the "status" field.
func (u *UserUpsertOne) SetStatus(v user.Status) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.SetStatus(v)
	})
}

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

// SetStorage sets the "storage" field.
func (u *UserUpsertOne) SetStorage(v int64) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.SetStorage(v)
	})
}

// AddStorage adds v to the "storage" field.
func (u *UserUpsertOne) AddStorage(v int64) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.AddStorage(v)
	})
}

// UpdateStorage sets the "storage" field to the value that was provided on create.
func (u *UserUpsertOne) UpdateStorage() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.UpdateStorage()
	})
}

// SetTwoFactorSecret sets the "two_factor_secret" field.
func (u *UserUpsertOne) SetTwoFactorSecret(v string) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.SetTwoFactorSecret(v)
	})
}

// UpdateTwoFactorSecret sets the "two_factor_secret" field to the value that was provided on create.
func (u *UserUpsertOne) UpdateTwoFactorSecret() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.UpdateTwoFactorSecret()
	})
}

// ClearTwoFactorSecret clears the value of the "two_factor_secret" field.
func (u *UserUpsertOne) ClearTwoFactorSecret() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.ClearTwoFactorSecret()
	})
}

// SetAvatar sets the "avatar" field.
func (u *UserUpsertOne) SetAvatar(v string) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.SetAvatar(v)
	})
}

// UpdateAvatar sets the "avatar" field to the value that was provided on create.
func (u *UserUpsertOne) UpdateAvatar() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.UpdateAvatar()
	})
}

// ClearAvatar clears the value of the "avatar" field.
func (u *UserUpsertOne) ClearAvatar() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.ClearAvatar()
	})
}

// SetSettings sets the "settings" field.
func (u *UserUpsertOne) SetSettings(v *types.UserSetting) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.SetSettings(v)
	})
}

// UpdateSettings sets the "settings" field to the value that was provided on create.
func (u *UserUpsertOne) UpdateSettings() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.UpdateSettings()
	})
}

// ClearSettings clears the value of the "settings" field.
func (u *UserUpsertOne) ClearSettings() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.ClearSettings()
	})
}

// SetGroupUsers sets the "group_users" field.
func (u *UserUpsertOne) SetGroupUsers(v int) *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.SetGroupUsers(v)
	})
}

// UpdateGroupUsers sets the "group_users" field to the value that was provided on create.
func (u *UserUpsertOne) UpdateGroupUsers() *UserUpsertOne {
	return u.Update(func(s *UserUpsert) {
		s.UpdateGroupUsers()
	})
}

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

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

func (m *UserCreate) SetRawID(t int) *UserCreate {
	m.mutation.SetRawID(t)
	return m
}

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

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

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

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

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

// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
// of the `INSERT` statement. For example:
//
//	client.User.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.UserUpsert) {
//			SetCreatedAt(v+v).
//		}).
//		Exec(ctx)
func (ucb *UserCreateBulk) OnConflict(opts ...sql.ConflictOption) *UserUpsertBulk {
	ucb.conflict = opts
	return &UserUpsertBulk{
		create: ucb,
	}
}

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

// UserUpsertBulk is the builder for "upsert"-ing
// a bulk of User nodes.
type UserUpsertBulk struct {
	create *UserCreateBulk
}

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

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

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

// SetUpdatedAt sets the "updated_at" field.
func (u *UserUpsertBulk) SetUpdatedAt(v time.Time) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.SetUpdatedAt(v)
	})
}

// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
func (u *UserUpsertBulk) UpdateUpdatedAt() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.UpdateUpdatedAt()
	})
}

// SetDeletedAt sets the "deleted_at" field.
func (u *UserUpsertBulk) SetDeletedAt(v time.Time) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.SetDeletedAt(v)
	})
}

// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
func (u *UserUpsertBulk) UpdateDeletedAt() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.UpdateDeletedAt()
	})
}

// ClearDeletedAt clears the value of the "deleted_at" field.
func (u *UserUpsertBulk) ClearDeletedAt() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.ClearDeletedAt()
	})
}

// SetEmail sets the "email" field.
func (u *UserUpsertBulk) SetEmail(v string) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.SetEmail(v)
	})
}

// UpdateEmail sets the "email" field to the value that was provided on create.
func (u *UserUpsertBulk) UpdateEmail() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.UpdateEmail()
	})
}

// SetNick sets the "nick" field.
func (u *UserUpsertBulk) SetNick(v string) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.SetNick(v)
	})
}

// UpdateNick sets the "nick" field to the value that was provided on create.
func (u *UserUpsertBulk) UpdateNick() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.UpdateNick()
	})
}

// SetPassword sets the "password" field.
func (u *UserUpsertBulk) SetPassword(v string) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.SetPassword(v)
	})
}

// UpdatePassword sets the "password" field to the value that was provided on create.
func (u *UserUpsertBulk) UpdatePassword() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.UpdatePassword()
	})
}

// ClearPassword clears the value of the "password" field.
func (u *UserUpsertBulk) ClearPassword() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.ClearPassword()
	})
}

// SetStatus sets the "status" field.
func (u *UserUpsertBulk) SetStatus(v user.Status) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.SetStatus(v)
	})
}

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

// SetStorage sets the "storage" field.
func (u *UserUpsertBulk) SetStorage(v int64) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.SetStorage(v)
	})
}

// AddStorage adds v to the "storage" field.
func (u *UserUpsertBulk) AddStorage(v int64) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.AddStorage(v)
	})
}

// UpdateStorage sets the "storage" field to the value that was provided on create.
func (u *UserUpsertBulk) UpdateStorage() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.UpdateStorage()
	})
}

// SetTwoFactorSecret sets the "two_factor_secret" field.
func (u *UserUpsertBulk) SetTwoFactorSecret(v string) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.SetTwoFactorSecret(v)
	})
}

// UpdateTwoFactorSecret sets the "two_factor_secret" field to the value that was provided on create.
func (u *UserUpsertBulk) UpdateTwoFactorSecret() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.UpdateTwoFactorSecret()
	})
}

// ClearTwoFactorSecret clears the value of the "two_factor_secret" field.
func (u *UserUpsertBulk) ClearTwoFactorSecret() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.ClearTwoFactorSecret()
	})
}

// SetAvatar sets the "avatar" field.
func (u *UserUpsertBulk) SetAvatar(v string) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.SetAvatar(v)
	})
}

// UpdateAvatar sets the "avatar" field to the value that was provided on create.
func (u *UserUpsertBulk) UpdateAvatar() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.UpdateAvatar()
	})
}

// ClearAvatar clears the value of the "avatar" field.
func (u *UserUpsertBulk) ClearAvatar() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.ClearAvatar()
	})
}

// SetSettings sets the "settings" field.
func (u *UserUpsertBulk) SetSettings(v *types.UserSetting) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.SetSettings(v)
	})
}

// UpdateSettings sets the "settings" field to the value that was provided on create.
func (u *UserUpsertBulk) UpdateSettings() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.UpdateSettings()
	})
}

// ClearSettings clears the value of the "settings" field.
func (u *UserUpsertBulk) ClearSettings() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.ClearSettings()
	})
}

// SetGroupUsers sets the "group_users" field.
func (u *UserUpsertBulk) SetGroupUsers(v int) *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.SetGroupUsers(v)
	})
}

// UpdateGroupUsers sets the "group_users" field to the value that was provided on create.
func (u *UserUpsertBulk) UpdateGroupUsers() *UserUpsertBulk {
	return u.Update(func(s *UserUpsert) {
		s.UpdateGroupUsers()
	})
}

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

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