// 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/anzhiyu-c/anheyu-app/ent/album"
)

// AlbumCreate is the builder for creating a Album entity.
type AlbumCreate struct {
	config
	mutation *AlbumMutation
	hooks    []Hook
	conflict []sql.ConflictOption
}

// SetDeletedAt sets the "deleted_at" field.
func (_c *AlbumCreate) SetDeletedAt(v time.Time) *AlbumCreate {
	_c.mutation.SetDeletedAt(v)
	return _c
}

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

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

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

// SetUpdatedAt sets the "updated_at" field.
func (_c *AlbumCreate) SetUpdatedAt(v time.Time) *AlbumCreate {
	_c.mutation.SetUpdatedAt(v)
	return _c
}

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

// SetImageURL sets the "image_url" field.
func (_c *AlbumCreate) SetImageURL(v string) *AlbumCreate {
	_c.mutation.SetImageURL(v)
	return _c
}

// SetBigImageURL sets the "big_image_url" field.
func (_c *AlbumCreate) SetBigImageURL(v string) *AlbumCreate {
	_c.mutation.SetBigImageURL(v)
	return _c
}

// SetNillableBigImageURL sets the "big_image_url" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableBigImageURL(v *string) *AlbumCreate {
	if v != nil {
		_c.SetBigImageURL(*v)
	}
	return _c
}

// SetDownloadURL sets the "download_url" field.
func (_c *AlbumCreate) SetDownloadURL(v string) *AlbumCreate {
	_c.mutation.SetDownloadURL(v)
	return _c
}

// SetNillableDownloadURL sets the "download_url" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableDownloadURL(v *string) *AlbumCreate {
	if v != nil {
		_c.SetDownloadURL(*v)
	}
	return _c
}

// SetThumbParam sets the "thumb_param" field.
func (_c *AlbumCreate) SetThumbParam(v string) *AlbumCreate {
	_c.mutation.SetThumbParam(v)
	return _c
}

// SetNillableThumbParam sets the "thumb_param" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableThumbParam(v *string) *AlbumCreate {
	if v != nil {
		_c.SetThumbParam(*v)
	}
	return _c
}

// SetBigParam sets the "big_param" field.
func (_c *AlbumCreate) SetBigParam(v string) *AlbumCreate {
	_c.mutation.SetBigParam(v)
	return _c
}

// SetNillableBigParam sets the "big_param" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableBigParam(v *string) *AlbumCreate {
	if v != nil {
		_c.SetBigParam(*v)
	}
	return _c
}

// SetTags sets the "tags" field.
func (_c *AlbumCreate) SetTags(v string) *AlbumCreate {
	_c.mutation.SetTags(v)
	return _c
}

// SetNillableTags sets the "tags" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableTags(v *string) *AlbumCreate {
	if v != nil {
		_c.SetTags(*v)
	}
	return _c
}

// SetViewCount sets the "view_count" field.
func (_c *AlbumCreate) SetViewCount(v int) *AlbumCreate {
	_c.mutation.SetViewCount(v)
	return _c
}

// SetNillableViewCount sets the "view_count" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableViewCount(v *int) *AlbumCreate {
	if v != nil {
		_c.SetViewCount(*v)
	}
	return _c
}

// SetDownloadCount sets the "download_count" field.
func (_c *AlbumCreate) SetDownloadCount(v int) *AlbumCreate {
	_c.mutation.SetDownloadCount(v)
	return _c
}

// SetNillableDownloadCount sets the "download_count" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableDownloadCount(v *int) *AlbumCreate {
	if v != nil {
		_c.SetDownloadCount(*v)
	}
	return _c
}

// SetWidth sets the "width" field.
func (_c *AlbumCreate) SetWidth(v int) *AlbumCreate {
	_c.mutation.SetWidth(v)
	return _c
}

// SetNillableWidth sets the "width" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableWidth(v *int) *AlbumCreate {
	if v != nil {
		_c.SetWidth(*v)
	}
	return _c
}

// SetHeight sets the "height" field.
func (_c *AlbumCreate) SetHeight(v int) *AlbumCreate {
	_c.mutation.SetHeight(v)
	return _c
}

// SetNillableHeight sets the "height" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableHeight(v *int) *AlbumCreate {
	if v != nil {
		_c.SetHeight(*v)
	}
	return _c
}

// SetFileSize sets the "file_size" field.
func (_c *AlbumCreate) SetFileSize(v int64) *AlbumCreate {
	_c.mutation.SetFileSize(v)
	return _c
}

// SetNillableFileSize sets the "file_size" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableFileSize(v *int64) *AlbumCreate {
	if v != nil {
		_c.SetFileSize(*v)
	}
	return _c
}

// SetFormat sets the "format" field.
func (_c *AlbumCreate) SetFormat(v string) *AlbumCreate {
	_c.mutation.SetFormat(v)
	return _c
}

// SetNillableFormat sets the "format" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableFormat(v *string) *AlbumCreate {
	if v != nil {
		_c.SetFormat(*v)
	}
	return _c
}

// SetAspectRatio sets the "aspect_ratio" field.
func (_c *AlbumCreate) SetAspectRatio(v string) *AlbumCreate {
	_c.mutation.SetAspectRatio(v)
	return _c
}

// SetNillableAspectRatio sets the "aspect_ratio" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableAspectRatio(v *string) *AlbumCreate {
	if v != nil {
		_c.SetAspectRatio(*v)
	}
	return _c
}

// SetFileHash sets the "file_hash" field.
func (_c *AlbumCreate) SetFileHash(v string) *AlbumCreate {
	_c.mutation.SetFileHash(v)
	return _c
}

// SetDisplayOrder sets the "display_order" field.
func (_c *AlbumCreate) SetDisplayOrder(v int) *AlbumCreate {
	_c.mutation.SetDisplayOrder(v)
	return _c
}

// SetNillableDisplayOrder sets the "display_order" field if the given value is not nil.
func (_c *AlbumCreate) SetNillableDisplayOrder(v *int) *AlbumCreate {
	if v != nil {
		_c.SetDisplayOrder(*v)
	}
	return _c
}

// SetID sets the "id" field.
func (_c *AlbumCreate) SetID(v uint) *AlbumCreate {
	_c.mutation.SetID(v)
	return _c
}

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

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

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

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

// ExecX is like Exec, but panics if an error occurs.
func (_c *AlbumCreate) 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 *AlbumCreate) defaults() error {
	if _, ok := _c.mutation.CreatedAt(); !ok {
		if album.DefaultCreatedAt == nil {
			return fmt.Errorf("ent: uninitialized album.DefaultCreatedAt (forgotten import ent/runtime?)")
		}
		v := album.DefaultCreatedAt()
		_c.mutation.SetCreatedAt(v)
	}
	if _, ok := _c.mutation.UpdatedAt(); !ok {
		if album.DefaultUpdatedAt == nil {
			return fmt.Errorf("ent: uninitialized album.DefaultUpdatedAt (forgotten import ent/runtime?)")
		}
		v := album.DefaultUpdatedAt()
		_c.mutation.SetUpdatedAt(v)
	}
	if _, ok := _c.mutation.ViewCount(); !ok {
		v := album.DefaultViewCount
		_c.mutation.SetViewCount(v)
	}
	if _, ok := _c.mutation.DownloadCount(); !ok {
		v := album.DefaultDownloadCount
		_c.mutation.SetDownloadCount(v)
	}
	if _, ok := _c.mutation.DisplayOrder(); !ok {
		v := album.DefaultDisplayOrder
		_c.mutation.SetDisplayOrder(v)
	}
	return nil
}

// check runs all checks and user-defined validators on the builder.
func (_c *AlbumCreate) check() error {
	if _, ok := _c.mutation.CreatedAt(); !ok {
		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Album.created_at"`)}
	}
	if _, ok := _c.mutation.UpdatedAt(); !ok {
		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Album.updated_at"`)}
	}
	if _, ok := _c.mutation.ImageURL(); !ok {
		return &ValidationError{Name: "image_url", err: errors.New(`ent: missing required field "Album.image_url"`)}
	}
	if v, ok := _c.mutation.ImageURL(); ok {
		if err := album.ImageURLValidator(v); err != nil {
			return &ValidationError{Name: "image_url", err: fmt.Errorf(`ent: validator failed for field "Album.image_url": %w`, err)}
		}
	}
	if v, ok := _c.mutation.BigImageURL(); ok {
		if err := album.BigImageURLValidator(v); err != nil {
			return &ValidationError{Name: "big_image_url", err: fmt.Errorf(`ent: validator failed for field "Album.big_image_url": %w`, err)}
		}
	}
	if v, ok := _c.mutation.DownloadURL(); ok {
		if err := album.DownloadURLValidator(v); err != nil {
			return &ValidationError{Name: "download_url", err: fmt.Errorf(`ent: validator failed for field "Album.download_url": %w`, err)}
		}
	}
	if v, ok := _c.mutation.ThumbParam(); ok {
		if err := album.ThumbParamValidator(v); err != nil {
			return &ValidationError{Name: "thumb_param", err: fmt.Errorf(`ent: validator failed for field "Album.thumb_param": %w`, err)}
		}
	}
	if v, ok := _c.mutation.BigParam(); ok {
		if err := album.BigParamValidator(v); err != nil {
			return &ValidationError{Name: "big_param", err: fmt.Errorf(`ent: validator failed for field "Album.big_param": %w`, err)}
		}
	}
	if v, ok := _c.mutation.Tags(); ok {
		if err := album.TagsValidator(v); err != nil {
			return &ValidationError{Name: "tags", err: fmt.Errorf(`ent: validator failed for field "Album.tags": %w`, err)}
		}
	}
	if _, ok := _c.mutation.ViewCount(); !ok {
		return &ValidationError{Name: "view_count", err: errors.New(`ent: missing required field "Album.view_count"`)}
	}
	if _, ok := _c.mutation.DownloadCount(); !ok {
		return &ValidationError{Name: "download_count", err: errors.New(`ent: missing required field "Album.download_count"`)}
	}
	if v, ok := _c.mutation.Format(); ok {
		if err := album.FormatValidator(v); err != nil {
			return &ValidationError{Name: "format", err: fmt.Errorf(`ent: validator failed for field "Album.format": %w`, err)}
		}
	}
	if v, ok := _c.mutation.AspectRatio(); ok {
		if err := album.AspectRatioValidator(v); err != nil {
			return &ValidationError{Name: "aspect_ratio", err: fmt.Errorf(`ent: validator failed for field "Album.aspect_ratio": %w`, err)}
		}
	}
	if _, ok := _c.mutation.FileHash(); !ok {
		return &ValidationError{Name: "file_hash", err: errors.New(`ent: missing required field "Album.file_hash"`)}
	}
	if v, ok := _c.mutation.FileHash(); ok {
		if err := album.FileHashValidator(v); err != nil {
			return &ValidationError{Name: "file_hash", err: fmt.Errorf(`ent: validator failed for field "Album.file_hash": %w`, err)}
		}
	}
	if _, ok := _c.mutation.DisplayOrder(); !ok {
		return &ValidationError{Name: "display_order", err: errors.New(`ent: missing required field "Album.display_order"`)}
	}
	return nil
}

func (_c *AlbumCreate) sqlSave(ctx context.Context) (*Album, 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
	}
	if _spec.ID.Value != _node.ID {
		id := _spec.ID.Value.(int64)
		_node.ID = uint(id)
	}
	_c.mutation.id = &_node.ID
	_c.mutation.done = true
	return _node, nil
}

func (_c *AlbumCreate) createSpec() (*Album, *sqlgraph.CreateSpec) {
	var (
		_node = &Album{config: _c.config}
		_spec = sqlgraph.NewCreateSpec(album.Table, sqlgraph.NewFieldSpec(album.FieldID, field.TypeUint))
	)
	_spec.OnConflict = _c.conflict
	if id, ok := _c.mutation.ID(); ok {
		_node.ID = id
		_spec.ID.Value = id
	}
	if value, ok := _c.mutation.DeletedAt(); ok {
		_spec.SetField(album.FieldDeletedAt, field.TypeTime, value)
		_node.DeletedAt = &value
	}
	if value, ok := _c.mutation.CreatedAt(); ok {
		_spec.SetField(album.FieldCreatedAt, field.TypeTime, value)
		_node.CreatedAt = value
	}
	if value, ok := _c.mutation.UpdatedAt(); ok {
		_spec.SetField(album.FieldUpdatedAt, field.TypeTime, value)
		_node.UpdatedAt = value
	}
	if value, ok := _c.mutation.ImageURL(); ok {
		_spec.SetField(album.FieldImageURL, field.TypeString, value)
		_node.ImageURL = value
	}
	if value, ok := _c.mutation.BigImageURL(); ok {
		_spec.SetField(album.FieldBigImageURL, field.TypeString, value)
		_node.BigImageURL = value
	}
	if value, ok := _c.mutation.DownloadURL(); ok {
		_spec.SetField(album.FieldDownloadURL, field.TypeString, value)
		_node.DownloadURL = value
	}
	if value, ok := _c.mutation.ThumbParam(); ok {
		_spec.SetField(album.FieldThumbParam, field.TypeString, value)
		_node.ThumbParam = value
	}
	if value, ok := _c.mutation.BigParam(); ok {
		_spec.SetField(album.FieldBigParam, field.TypeString, value)
		_node.BigParam = value
	}
	if value, ok := _c.mutation.Tags(); ok {
		_spec.SetField(album.FieldTags, field.TypeString, value)
		_node.Tags = value
	}
	if value, ok := _c.mutation.ViewCount(); ok {
		_spec.SetField(album.FieldViewCount, field.TypeInt, value)
		_node.ViewCount = value
	}
	if value, ok := _c.mutation.DownloadCount(); ok {
		_spec.SetField(album.FieldDownloadCount, field.TypeInt, value)
		_node.DownloadCount = value
	}
	if value, ok := _c.mutation.Width(); ok {
		_spec.SetField(album.FieldWidth, field.TypeInt, value)
		_node.Width = value
	}
	if value, ok := _c.mutation.Height(); ok {
		_spec.SetField(album.FieldHeight, field.TypeInt, value)
		_node.Height = value
	}
	if value, ok := _c.mutation.FileSize(); ok {
		_spec.SetField(album.FieldFileSize, field.TypeInt64, value)
		_node.FileSize = value
	}
	if value, ok := _c.mutation.Format(); ok {
		_spec.SetField(album.FieldFormat, field.TypeString, value)
		_node.Format = value
	}
	if value, ok := _c.mutation.AspectRatio(); ok {
		_spec.SetField(album.FieldAspectRatio, field.TypeString, value)
		_node.AspectRatio = value
	}
	if value, ok := _c.mutation.FileHash(); ok {
		_spec.SetField(album.FieldFileHash, field.TypeString, value)
		_node.FileHash = value
	}
	if value, ok := _c.mutation.DisplayOrder(); ok {
		_spec.SetField(album.FieldDisplayOrder, field.TypeInt, value)
		_node.DisplayOrder = value
	}
	return _node, _spec
}

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

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

type (
	// AlbumUpsertOne is the builder for "upsert"-ing
	//  one Album node.
	AlbumUpsertOne struct {
		create *AlbumCreate
	}

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

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

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

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

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

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

// SetImageURL sets the "image_url" field.
func (u *AlbumUpsert) SetImageURL(v string) *AlbumUpsert {
	u.Set(album.FieldImageURL, v)
	return u
}

// UpdateImageURL sets the "image_url" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateImageURL() *AlbumUpsert {
	u.SetExcluded(album.FieldImageURL)
	return u
}

// SetBigImageURL sets the "big_image_url" field.
func (u *AlbumUpsert) SetBigImageURL(v string) *AlbumUpsert {
	u.Set(album.FieldBigImageURL, v)
	return u
}

// UpdateBigImageURL sets the "big_image_url" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateBigImageURL() *AlbumUpsert {
	u.SetExcluded(album.FieldBigImageURL)
	return u
}

// ClearBigImageURL clears the value of the "big_image_url" field.
func (u *AlbumUpsert) ClearBigImageURL() *AlbumUpsert {
	u.SetNull(album.FieldBigImageURL)
	return u
}

// SetDownloadURL sets the "download_url" field.
func (u *AlbumUpsert) SetDownloadURL(v string) *AlbumUpsert {
	u.Set(album.FieldDownloadURL, v)
	return u
}

// UpdateDownloadURL sets the "download_url" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateDownloadURL() *AlbumUpsert {
	u.SetExcluded(album.FieldDownloadURL)
	return u
}

// ClearDownloadURL clears the value of the "download_url" field.
func (u *AlbumUpsert) ClearDownloadURL() *AlbumUpsert {
	u.SetNull(album.FieldDownloadURL)
	return u
}

// SetThumbParam sets the "thumb_param" field.
func (u *AlbumUpsert) SetThumbParam(v string) *AlbumUpsert {
	u.Set(album.FieldThumbParam, v)
	return u
}

// UpdateThumbParam sets the "thumb_param" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateThumbParam() *AlbumUpsert {
	u.SetExcluded(album.FieldThumbParam)
	return u
}

// ClearThumbParam clears the value of the "thumb_param" field.
func (u *AlbumUpsert) ClearThumbParam() *AlbumUpsert {
	u.SetNull(album.FieldThumbParam)
	return u
}

// SetBigParam sets the "big_param" field.
func (u *AlbumUpsert) SetBigParam(v string) *AlbumUpsert {
	u.Set(album.FieldBigParam, v)
	return u
}

// UpdateBigParam sets the "big_param" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateBigParam() *AlbumUpsert {
	u.SetExcluded(album.FieldBigParam)
	return u
}

// ClearBigParam clears the value of the "big_param" field.
func (u *AlbumUpsert) ClearBigParam() *AlbumUpsert {
	u.SetNull(album.FieldBigParam)
	return u
}

// SetTags sets the "tags" field.
func (u *AlbumUpsert) SetTags(v string) *AlbumUpsert {
	u.Set(album.FieldTags, v)
	return u
}

// UpdateTags sets the "tags" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateTags() *AlbumUpsert {
	u.SetExcluded(album.FieldTags)
	return u
}

// ClearTags clears the value of the "tags" field.
func (u *AlbumUpsert) ClearTags() *AlbumUpsert {
	u.SetNull(album.FieldTags)
	return u
}

// SetViewCount sets the "view_count" field.
func (u *AlbumUpsert) SetViewCount(v int) *AlbumUpsert {
	u.Set(album.FieldViewCount, v)
	return u
}

// UpdateViewCount sets the "view_count" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateViewCount() *AlbumUpsert {
	u.SetExcluded(album.FieldViewCount)
	return u
}

// AddViewCount adds v to the "view_count" field.
func (u *AlbumUpsert) AddViewCount(v int) *AlbumUpsert {
	u.Add(album.FieldViewCount, v)
	return u
}

// SetDownloadCount sets the "download_count" field.
func (u *AlbumUpsert) SetDownloadCount(v int) *AlbumUpsert {
	u.Set(album.FieldDownloadCount, v)
	return u
}

// UpdateDownloadCount sets the "download_count" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateDownloadCount() *AlbumUpsert {
	u.SetExcluded(album.FieldDownloadCount)
	return u
}

// AddDownloadCount adds v to the "download_count" field.
func (u *AlbumUpsert) AddDownloadCount(v int) *AlbumUpsert {
	u.Add(album.FieldDownloadCount, v)
	return u
}

// SetWidth sets the "width" field.
func (u *AlbumUpsert) SetWidth(v int) *AlbumUpsert {
	u.Set(album.FieldWidth, v)
	return u
}

// UpdateWidth sets the "width" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateWidth() *AlbumUpsert {
	u.SetExcluded(album.FieldWidth)
	return u
}

// AddWidth adds v to the "width" field.
func (u *AlbumUpsert) AddWidth(v int) *AlbumUpsert {
	u.Add(album.FieldWidth, v)
	return u
}

// ClearWidth clears the value of the "width" field.
func (u *AlbumUpsert) ClearWidth() *AlbumUpsert {
	u.SetNull(album.FieldWidth)
	return u
}

// SetHeight sets the "height" field.
func (u *AlbumUpsert) SetHeight(v int) *AlbumUpsert {
	u.Set(album.FieldHeight, v)
	return u
}

// UpdateHeight sets the "height" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateHeight() *AlbumUpsert {
	u.SetExcluded(album.FieldHeight)
	return u
}

// AddHeight adds v to the "height" field.
func (u *AlbumUpsert) AddHeight(v int) *AlbumUpsert {
	u.Add(album.FieldHeight, v)
	return u
}

// ClearHeight clears the value of the "height" field.
func (u *AlbumUpsert) ClearHeight() *AlbumUpsert {
	u.SetNull(album.FieldHeight)
	return u
}

// SetFileSize sets the "file_size" field.
func (u *AlbumUpsert) SetFileSize(v int64) *AlbumUpsert {
	u.Set(album.FieldFileSize, v)
	return u
}

// UpdateFileSize sets the "file_size" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateFileSize() *AlbumUpsert {
	u.SetExcluded(album.FieldFileSize)
	return u
}

// AddFileSize adds v to the "file_size" field.
func (u *AlbumUpsert) AddFileSize(v int64) *AlbumUpsert {
	u.Add(album.FieldFileSize, v)
	return u
}

// ClearFileSize clears the value of the "file_size" field.
func (u *AlbumUpsert) ClearFileSize() *AlbumUpsert {
	u.SetNull(album.FieldFileSize)
	return u
}

// SetFormat sets the "format" field.
func (u *AlbumUpsert) SetFormat(v string) *AlbumUpsert {
	u.Set(album.FieldFormat, v)
	return u
}

// UpdateFormat sets the "format" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateFormat() *AlbumUpsert {
	u.SetExcluded(album.FieldFormat)
	return u
}

// ClearFormat clears the value of the "format" field.
func (u *AlbumUpsert) ClearFormat() *AlbumUpsert {
	u.SetNull(album.FieldFormat)
	return u
}

// SetAspectRatio sets the "aspect_ratio" field.
func (u *AlbumUpsert) SetAspectRatio(v string) *AlbumUpsert {
	u.Set(album.FieldAspectRatio, v)
	return u
}

// UpdateAspectRatio sets the "aspect_ratio" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateAspectRatio() *AlbumUpsert {
	u.SetExcluded(album.FieldAspectRatio)
	return u
}

// ClearAspectRatio clears the value of the "aspect_ratio" field.
func (u *AlbumUpsert) ClearAspectRatio() *AlbumUpsert {
	u.SetNull(album.FieldAspectRatio)
	return u
}

// SetFileHash sets the "file_hash" field.
func (u *AlbumUpsert) SetFileHash(v string) *AlbumUpsert {
	u.Set(album.FieldFileHash, v)
	return u
}

// UpdateFileHash sets the "file_hash" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateFileHash() *AlbumUpsert {
	u.SetExcluded(album.FieldFileHash)
	return u
}

// SetDisplayOrder sets the "display_order" field.
func (u *AlbumUpsert) SetDisplayOrder(v int) *AlbumUpsert {
	u.Set(album.FieldDisplayOrder, v)
	return u
}

// UpdateDisplayOrder sets the "display_order" field to the value that was provided on create.
func (u *AlbumUpsert) UpdateDisplayOrder() *AlbumUpsert {
	u.SetExcluded(album.FieldDisplayOrder)
	return u
}

// AddDisplayOrder adds v to the "display_order" field.
func (u *AlbumUpsert) AddDisplayOrder(v int) *AlbumUpsert {
	u.Add(album.FieldDisplayOrder, v)
	return u
}

// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
// Using this option is equivalent to using:
//
//	client.Album.Create().
//		OnConflict(
//			sql.ResolveWithNewValues(),
//			sql.ResolveWith(func(u *sql.UpdateSet) {
//				u.SetIgnore(album.FieldID)
//			}),
//		).
//		Exec(ctx)
func (u *AlbumUpsertOne) UpdateNewValues() *AlbumUpsertOne {
	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
		if _, exists := u.create.mutation.ID(); exists {
			s.SetIgnore(album.FieldID)
		}
		if _, exists := u.create.mutation.CreatedAt(); exists {
			s.SetIgnore(album.FieldCreatedAt)
		}
	}))
	return u
}

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

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

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

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

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

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

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

// SetImageURL sets the "image_url" field.
func (u *AlbumUpsertOne) SetImageURL(v string) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetImageURL(v)
	})
}

// UpdateImageURL sets the "image_url" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateImageURL() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateImageURL()
	})
}

// SetBigImageURL sets the "big_image_url" field.
func (u *AlbumUpsertOne) SetBigImageURL(v string) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetBigImageURL(v)
	})
}

// UpdateBigImageURL sets the "big_image_url" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateBigImageURL() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateBigImageURL()
	})
}

// ClearBigImageURL clears the value of the "big_image_url" field.
func (u *AlbumUpsertOne) ClearBigImageURL() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearBigImageURL()
	})
}

// SetDownloadURL sets the "download_url" field.
func (u *AlbumUpsertOne) SetDownloadURL(v string) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetDownloadURL(v)
	})
}

// UpdateDownloadURL sets the "download_url" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateDownloadURL() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateDownloadURL()
	})
}

// ClearDownloadURL clears the value of the "download_url" field.
func (u *AlbumUpsertOne) ClearDownloadURL() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearDownloadURL()
	})
}

// SetThumbParam sets the "thumb_param" field.
func (u *AlbumUpsertOne) SetThumbParam(v string) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetThumbParam(v)
	})
}

// UpdateThumbParam sets the "thumb_param" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateThumbParam() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateThumbParam()
	})
}

// ClearThumbParam clears the value of the "thumb_param" field.
func (u *AlbumUpsertOne) ClearThumbParam() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearThumbParam()
	})
}

// SetBigParam sets the "big_param" field.
func (u *AlbumUpsertOne) SetBigParam(v string) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetBigParam(v)
	})
}

// UpdateBigParam sets the "big_param" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateBigParam() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateBigParam()
	})
}

// ClearBigParam clears the value of the "big_param" field.
func (u *AlbumUpsertOne) ClearBigParam() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearBigParam()
	})
}

// SetTags sets the "tags" field.
func (u *AlbumUpsertOne) SetTags(v string) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetTags(v)
	})
}

// UpdateTags sets the "tags" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateTags() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateTags()
	})
}

// ClearTags clears the value of the "tags" field.
func (u *AlbumUpsertOne) ClearTags() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearTags()
	})
}

// SetViewCount sets the "view_count" field.
func (u *AlbumUpsertOne) SetViewCount(v int) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetViewCount(v)
	})
}

// AddViewCount adds v to the "view_count" field.
func (u *AlbumUpsertOne) AddViewCount(v int) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.AddViewCount(v)
	})
}

// UpdateViewCount sets the "view_count" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateViewCount() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateViewCount()
	})
}

// SetDownloadCount sets the "download_count" field.
func (u *AlbumUpsertOne) SetDownloadCount(v int) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetDownloadCount(v)
	})
}

// AddDownloadCount adds v to the "download_count" field.
func (u *AlbumUpsertOne) AddDownloadCount(v int) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.AddDownloadCount(v)
	})
}

// UpdateDownloadCount sets the "download_count" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateDownloadCount() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateDownloadCount()
	})
}

// SetWidth sets the "width" field.
func (u *AlbumUpsertOne) SetWidth(v int) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetWidth(v)
	})
}

// AddWidth adds v to the "width" field.
func (u *AlbumUpsertOne) AddWidth(v int) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.AddWidth(v)
	})
}

// UpdateWidth sets the "width" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateWidth() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateWidth()
	})
}

// ClearWidth clears the value of the "width" field.
func (u *AlbumUpsertOne) ClearWidth() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearWidth()
	})
}

// SetHeight sets the "height" field.
func (u *AlbumUpsertOne) SetHeight(v int) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetHeight(v)
	})
}

// AddHeight adds v to the "height" field.
func (u *AlbumUpsertOne) AddHeight(v int) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.AddHeight(v)
	})
}

// UpdateHeight sets the "height" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateHeight() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateHeight()
	})
}

// ClearHeight clears the value of the "height" field.
func (u *AlbumUpsertOne) ClearHeight() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearHeight()
	})
}

// SetFileSize sets the "file_size" field.
func (u *AlbumUpsertOne) SetFileSize(v int64) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetFileSize(v)
	})
}

// AddFileSize adds v to the "file_size" field.
func (u *AlbumUpsertOne) AddFileSize(v int64) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.AddFileSize(v)
	})
}

// UpdateFileSize sets the "file_size" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateFileSize() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateFileSize()
	})
}

// ClearFileSize clears the value of the "file_size" field.
func (u *AlbumUpsertOne) ClearFileSize() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearFileSize()
	})
}

// SetFormat sets the "format" field.
func (u *AlbumUpsertOne) SetFormat(v string) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetFormat(v)
	})
}

// UpdateFormat sets the "format" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateFormat() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateFormat()
	})
}

// ClearFormat clears the value of the "format" field.
func (u *AlbumUpsertOne) ClearFormat() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearFormat()
	})
}

// SetAspectRatio sets the "aspect_ratio" field.
func (u *AlbumUpsertOne) SetAspectRatio(v string) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetAspectRatio(v)
	})
}

// UpdateAspectRatio sets the "aspect_ratio" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateAspectRatio() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateAspectRatio()
	})
}

// ClearAspectRatio clears the value of the "aspect_ratio" field.
func (u *AlbumUpsertOne) ClearAspectRatio() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearAspectRatio()
	})
}

// SetFileHash sets the "file_hash" field.
func (u *AlbumUpsertOne) SetFileHash(v string) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetFileHash(v)
	})
}

// UpdateFileHash sets the "file_hash" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateFileHash() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateFileHash()
	})
}

// SetDisplayOrder sets the "display_order" field.
func (u *AlbumUpsertOne) SetDisplayOrder(v int) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.SetDisplayOrder(v)
	})
}

// AddDisplayOrder adds v to the "display_order" field.
func (u *AlbumUpsertOne) AddDisplayOrder(v int) *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.AddDisplayOrder(v)
	})
}

// UpdateDisplayOrder sets the "display_order" field to the value that was provided on create.
func (u *AlbumUpsertOne) UpdateDisplayOrder() *AlbumUpsertOne {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateDisplayOrder()
	})
}

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

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

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

// Save creates the Album entities in the database.
func (_c *AlbumCreateBulk) Save(ctx context.Context) ([]*Album, error) {
	if _c.err != nil {
		return nil, _c.err
	}
	specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
	nodes := make([]*Album, 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.(*AlbumMutation)
				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 && nodes[i].ID == 0 {
					id := specs[i].ID.Value.(int64)
					nodes[i].ID = uint(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 *AlbumCreateBulk) SaveX(ctx context.Context) []*Album {
	v, err := _c.Save(ctx)
	if err != nil {
		panic(err)
	}
	return v
}

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

// ExecX is like Exec, but panics if an error occurs.
func (_c *AlbumCreateBulk) 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.Album.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.AlbumUpsert) {
//			SetDeletedAt(v+v).
//		}).
//		Exec(ctx)
func (_c *AlbumCreateBulk) OnConflict(opts ...sql.ConflictOption) *AlbumUpsertBulk {
	_c.conflict = opts
	return &AlbumUpsertBulk{
		create: _c,
	}
}

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

// AlbumUpsertBulk is the builder for "upsert"-ing
// a bulk of Album nodes.
type AlbumUpsertBulk struct {
	create *AlbumCreateBulk
}

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

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

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

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

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

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

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

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

// SetImageURL sets the "image_url" field.
func (u *AlbumUpsertBulk) SetImageURL(v string) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetImageURL(v)
	})
}

// UpdateImageURL sets the "image_url" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateImageURL() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateImageURL()
	})
}

// SetBigImageURL sets the "big_image_url" field.
func (u *AlbumUpsertBulk) SetBigImageURL(v string) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetBigImageURL(v)
	})
}

// UpdateBigImageURL sets the "big_image_url" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateBigImageURL() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateBigImageURL()
	})
}

// ClearBigImageURL clears the value of the "big_image_url" field.
func (u *AlbumUpsertBulk) ClearBigImageURL() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearBigImageURL()
	})
}

// SetDownloadURL sets the "download_url" field.
func (u *AlbumUpsertBulk) SetDownloadURL(v string) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetDownloadURL(v)
	})
}

// UpdateDownloadURL sets the "download_url" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateDownloadURL() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateDownloadURL()
	})
}

// ClearDownloadURL clears the value of the "download_url" field.
func (u *AlbumUpsertBulk) ClearDownloadURL() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearDownloadURL()
	})
}

// SetThumbParam sets the "thumb_param" field.
func (u *AlbumUpsertBulk) SetThumbParam(v string) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetThumbParam(v)
	})
}

// UpdateThumbParam sets the "thumb_param" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateThumbParam() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateThumbParam()
	})
}

// ClearThumbParam clears the value of the "thumb_param" field.
func (u *AlbumUpsertBulk) ClearThumbParam() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearThumbParam()
	})
}

// SetBigParam sets the "big_param" field.
func (u *AlbumUpsertBulk) SetBigParam(v string) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetBigParam(v)
	})
}

// UpdateBigParam sets the "big_param" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateBigParam() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateBigParam()
	})
}

// ClearBigParam clears the value of the "big_param" field.
func (u *AlbumUpsertBulk) ClearBigParam() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearBigParam()
	})
}

// SetTags sets the "tags" field.
func (u *AlbumUpsertBulk) SetTags(v string) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetTags(v)
	})
}

// UpdateTags sets the "tags" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateTags() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateTags()
	})
}

// ClearTags clears the value of the "tags" field.
func (u *AlbumUpsertBulk) ClearTags() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearTags()
	})
}

// SetViewCount sets the "view_count" field.
func (u *AlbumUpsertBulk) SetViewCount(v int) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetViewCount(v)
	})
}

// AddViewCount adds v to the "view_count" field.
func (u *AlbumUpsertBulk) AddViewCount(v int) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.AddViewCount(v)
	})
}

// UpdateViewCount sets the "view_count" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateViewCount() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateViewCount()
	})
}

// SetDownloadCount sets the "download_count" field.
func (u *AlbumUpsertBulk) SetDownloadCount(v int) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetDownloadCount(v)
	})
}

// AddDownloadCount adds v to the "download_count" field.
func (u *AlbumUpsertBulk) AddDownloadCount(v int) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.AddDownloadCount(v)
	})
}

// UpdateDownloadCount sets the "download_count" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateDownloadCount() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateDownloadCount()
	})
}

// SetWidth sets the "width" field.
func (u *AlbumUpsertBulk) SetWidth(v int) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetWidth(v)
	})
}

// AddWidth adds v to the "width" field.
func (u *AlbumUpsertBulk) AddWidth(v int) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.AddWidth(v)
	})
}

// UpdateWidth sets the "width" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateWidth() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateWidth()
	})
}

// ClearWidth clears the value of the "width" field.
func (u *AlbumUpsertBulk) ClearWidth() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearWidth()
	})
}

// SetHeight sets the "height" field.
func (u *AlbumUpsertBulk) SetHeight(v int) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetHeight(v)
	})
}

// AddHeight adds v to the "height" field.
func (u *AlbumUpsertBulk) AddHeight(v int) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.AddHeight(v)
	})
}

// UpdateHeight sets the "height" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateHeight() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateHeight()
	})
}

// ClearHeight clears the value of the "height" field.
func (u *AlbumUpsertBulk) ClearHeight() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearHeight()
	})
}

// SetFileSize sets the "file_size" field.
func (u *AlbumUpsertBulk) SetFileSize(v int64) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetFileSize(v)
	})
}

// AddFileSize adds v to the "file_size" field.
func (u *AlbumUpsertBulk) AddFileSize(v int64) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.AddFileSize(v)
	})
}

// UpdateFileSize sets the "file_size" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateFileSize() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateFileSize()
	})
}

// ClearFileSize clears the value of the "file_size" field.
func (u *AlbumUpsertBulk) ClearFileSize() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearFileSize()
	})
}

// SetFormat sets the "format" field.
func (u *AlbumUpsertBulk) SetFormat(v string) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetFormat(v)
	})
}

// UpdateFormat sets the "format" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateFormat() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateFormat()
	})
}

// ClearFormat clears the value of the "format" field.
func (u *AlbumUpsertBulk) ClearFormat() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearFormat()
	})
}

// SetAspectRatio sets the "aspect_ratio" field.
func (u *AlbumUpsertBulk) SetAspectRatio(v string) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetAspectRatio(v)
	})
}

// UpdateAspectRatio sets the "aspect_ratio" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateAspectRatio() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateAspectRatio()
	})
}

// ClearAspectRatio clears the value of the "aspect_ratio" field.
func (u *AlbumUpsertBulk) ClearAspectRatio() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.ClearAspectRatio()
	})
}

// SetFileHash sets the "file_hash" field.
func (u *AlbumUpsertBulk) SetFileHash(v string) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetFileHash(v)
	})
}

// UpdateFileHash sets the "file_hash" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateFileHash() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateFileHash()
	})
}

// SetDisplayOrder sets the "display_order" field.
func (u *AlbumUpsertBulk) SetDisplayOrder(v int) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.SetDisplayOrder(v)
	})
}

// AddDisplayOrder adds v to the "display_order" field.
func (u *AlbumUpsertBulk) AddDisplayOrder(v int) *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.AddDisplayOrder(v)
	})
}

// UpdateDisplayOrder sets the "display_order" field to the value that was provided on create.
func (u *AlbumUpsertBulk) UpdateDisplayOrder() *AlbumUpsertBulk {
	return u.Update(func(s *AlbumUpsert) {
		s.UpdateDisplayOrder()
	})
}

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

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