// Code generated by ent, DO NOT EDIT.

package models

import (
	"context"
	"errors"
	"fmt"
	"juwan-backend/app/user_verifications/rpc/internal/models/predicate"
	"juwan-backend/app/user_verifications/rpc/internal/models/schema"
	"juwan-backend/app/user_verifications/rpc/internal/models/userverifications"
	"sync"
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect/sql"
)

const (
	// Operation types.
	OpCreate    = ent.OpCreate
	OpDelete    = ent.OpDelete
	OpDeleteOne = ent.OpDeleteOne
	OpUpdate    = ent.OpUpdate
	OpUpdateOne = ent.OpUpdateOne

	// Node types.
	TypeUserVerifications = "UserVerifications"
)

// UserVerificationsMutation represents an operation that mutates the UserVerifications nodes in the graph.
type UserVerificationsMutation struct {
	config
	op             Op
	typ            string
	id             *int64
	user_id        *int64
	adduser_id     *int64
	role           *string
	status         *string
	materials      *schema.MaterialStruct
	reject_reason  *string
	reviewed_by    *int64
	addreviewed_by *int64
	reviewed_at    *time.Time
	created_at     *time.Time
	updated_at     *time.Time
	clearedFields  map[string]struct{}
	done           bool
	oldValue       func(context.Context) (*UserVerifications, error)
	predicates     []predicate.UserVerifications
}

var _ ent.Mutation = (*UserVerificationsMutation)(nil)

// userverificationsOption allows management of the mutation configuration using functional options.
type userverificationsOption func(*UserVerificationsMutation)

// newUserVerificationsMutation creates new mutation for the UserVerifications entity.
func newUserVerificationsMutation(c config, op Op, opts ...userverificationsOption) *UserVerificationsMutation {
	m := &UserVerificationsMutation{
		config:        c,
		op:            op,
		typ:           TypeUserVerifications,
		clearedFields: make(map[string]struct{}),
	}
	for _, opt := range opts {
		opt(m)
	}
	return m
}

// withUserVerificationsID sets the ID field of the mutation.
func withUserVerificationsID(id int64) userverificationsOption {
	return func(m *UserVerificationsMutation) {
		var (
			err   error
			once  sync.Once
			value *UserVerifications
		)
		m.oldValue = func(ctx context.Context) (*UserVerifications, error) {
			once.Do(func() {
				if m.done {
					err = errors.New("querying old values post mutation is not allowed")
				} else {
					value, err = m.Client().UserVerifications.Get(ctx, id)
				}
			})
			return value, err
		}
		m.id = &id
	}
}

// withUserVerifications sets the old UserVerifications of the mutation.
func withUserVerifications(node *UserVerifications) userverificationsOption {
	return func(m *UserVerificationsMutation) {
		m.oldValue = func(context.Context) (*UserVerifications, error) {
			return node, nil
		}
		m.id = &node.ID
	}
}

// Client returns a new `ent.Client` from the mutation. If the mutation was
// executed in a transaction (ent.Tx), a transactional client is returned.
func (m UserVerificationsMutation) Client() *Client {
	client := &Client{config: m.config}
	client.init()
	return client
}

// Tx returns an `ent.Tx` for mutations that were executed in transactions;
// it returns an error otherwise.
func (m UserVerificationsMutation) Tx() (*Tx, error) {
	if _, ok := m.driver.(*txDriver); !ok {
		return nil, errors.New("models: mutation is not running in a transaction")
	}
	tx := &Tx{config: m.config}
	tx.init()
	return tx, nil
}

// SetID sets the value of the id field. Note that this
// operation is only accepted on creation of UserVerifications entities.
func (m *UserVerificationsMutation) SetID(id int64) {
	m.id = &id
}

// ID returns the ID value in the mutation. Note that the ID is only available
// if it was provided to the builder or after it was returned from the database.
func (m *UserVerificationsMutation) ID() (id int64, exists bool) {
	if m.id == nil {
		return
	}
	return *m.id, true
}

// IDs queries the database and returns the entity ids that match the mutation's predicate.
// That means, if the mutation is applied within a transaction with an isolation level such
// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
// or updated by the mutation.
func (m *UserVerificationsMutation) IDs(ctx context.Context) ([]int64, error) {
	switch {
	case m.op.Is(OpUpdateOne | OpDeleteOne):
		id, exists := m.ID()
		if exists {
			return []int64{id}, nil
		}
		fallthrough
	case m.op.Is(OpUpdate | OpDelete):
		return m.Client().UserVerifications.Query().Where(m.predicates...).IDs(ctx)
	default:
		return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
	}
}

// SetUserID sets the "user_id" field.
func (m *UserVerificationsMutation) SetUserID(i int64) {
	m.user_id = &i
	m.adduser_id = nil
}

// UserID returns the value of the "user_id" field in the mutation.
func (m *UserVerificationsMutation) UserID() (r int64, exists bool) {
	v := m.user_id
	if v == nil {
		return
	}
	return *v, true
}

// OldUserID returns the old "user_id" field's value of the UserVerifications entity.
// If the UserVerifications object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserVerificationsMutation) OldUserID(ctx context.Context) (v int64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUserID is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUserID requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUserID: %w", err)
	}
	return oldValue.UserID, nil
}

// AddUserID adds i to the "user_id" field.
func (m *UserVerificationsMutation) AddUserID(i int64) {
	if m.adduser_id != nil {
		*m.adduser_id += i
	} else {
		m.adduser_id = &i
	}
}

// AddedUserID returns the value that was added to the "user_id" field in this mutation.
func (m *UserVerificationsMutation) AddedUserID() (r int64, exists bool) {
	v := m.adduser_id
	if v == nil {
		return
	}
	return *v, true
}

// ResetUserID resets all changes to the "user_id" field.
func (m *UserVerificationsMutation) ResetUserID() {
	m.user_id = nil
	m.adduser_id = nil
}

// SetRole sets the "role" field.
func (m *UserVerificationsMutation) SetRole(s string) {
	m.role = &s
}

// Role returns the value of the "role" field in the mutation.
func (m *UserVerificationsMutation) Role() (r string, exists bool) {
	v := m.role
	if v == nil {
		return
	}
	return *v, true
}

// OldRole returns the old "role" field's value of the UserVerifications entity.
// If the UserVerifications object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserVerificationsMutation) OldRole(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldRole is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldRole requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRole: %w", err)
	}
	return oldValue.Role, nil
}

// ResetRole resets all changes to the "role" field.
func (m *UserVerificationsMutation) ResetRole() {
	m.role = nil
}

// SetStatus sets the "status" field.
func (m *UserVerificationsMutation) SetStatus(s string) {
	m.status = &s
}

// Status returns the value of the "status" field in the mutation.
func (m *UserVerificationsMutation) Status() (r string, exists bool) {
	v := m.status
	if v == nil {
		return
	}
	return *v, true
}

// OldStatus returns the old "status" field's value of the UserVerifications entity.
// If the UserVerifications object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserVerificationsMutation) OldStatus(ctx context.Context) (v string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldStatus is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldStatus requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldStatus: %w", err)
	}
	return oldValue.Status, nil
}

// ResetStatus resets all changes to the "status" field.
func (m *UserVerificationsMutation) ResetStatus() {
	m.status = nil
}

// SetMaterials sets the "materials" field.
func (m *UserVerificationsMutation) SetMaterials(ss schema.MaterialStruct) {
	m.materials = &ss
}

// Materials returns the value of the "materials" field in the mutation.
func (m *UserVerificationsMutation) Materials() (r schema.MaterialStruct, exists bool) {
	v := m.materials
	if v == nil {
		return
	}
	return *v, true
}

// OldMaterials returns the old "materials" field's value of the UserVerifications entity.
// If the UserVerifications object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserVerificationsMutation) OldMaterials(ctx context.Context) (v schema.MaterialStruct, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldMaterials is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldMaterials requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldMaterials: %w", err)
	}
	return oldValue.Materials, nil
}

// ResetMaterials resets all changes to the "materials" field.
func (m *UserVerificationsMutation) ResetMaterials() {
	m.materials = nil
}

// SetRejectReason sets the "reject_reason" field.
func (m *UserVerificationsMutation) SetRejectReason(s string) {
	m.reject_reason = &s
}

// RejectReason returns the value of the "reject_reason" field in the mutation.
func (m *UserVerificationsMutation) RejectReason() (r string, exists bool) {
	v := m.reject_reason
	if v == nil {
		return
	}
	return *v, true
}

// OldRejectReason returns the old "reject_reason" field's value of the UserVerifications entity.
// If the UserVerifications object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserVerificationsMutation) OldRejectReason(ctx context.Context) (v *string, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldRejectReason is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldRejectReason requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldRejectReason: %w", err)
	}
	return oldValue.RejectReason, nil
}

// ClearRejectReason clears the value of the "reject_reason" field.
func (m *UserVerificationsMutation) ClearRejectReason() {
	m.reject_reason = nil
	m.clearedFields[userverifications.FieldRejectReason] = struct{}{}
}

// RejectReasonCleared returns if the "reject_reason" field was cleared in this mutation.
func (m *UserVerificationsMutation) RejectReasonCleared() bool {
	_, ok := m.clearedFields[userverifications.FieldRejectReason]
	return ok
}

// ResetRejectReason resets all changes to the "reject_reason" field.
func (m *UserVerificationsMutation) ResetRejectReason() {
	m.reject_reason = nil
	delete(m.clearedFields, userverifications.FieldRejectReason)
}

// SetReviewedBy sets the "reviewed_by" field.
func (m *UserVerificationsMutation) SetReviewedBy(i int64) {
	m.reviewed_by = &i
	m.addreviewed_by = nil
}

// ReviewedBy returns the value of the "reviewed_by" field in the mutation.
func (m *UserVerificationsMutation) ReviewedBy() (r int64, exists bool) {
	v := m.reviewed_by
	if v == nil {
		return
	}
	return *v, true
}

// OldReviewedBy returns the old "reviewed_by" field's value of the UserVerifications entity.
// If the UserVerifications object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserVerificationsMutation) OldReviewedBy(ctx context.Context) (v *int64, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldReviewedBy is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldReviewedBy requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldReviewedBy: %w", err)
	}
	return oldValue.ReviewedBy, nil
}

// AddReviewedBy adds i to the "reviewed_by" field.
func (m *UserVerificationsMutation) AddReviewedBy(i int64) {
	if m.addreviewed_by != nil {
		*m.addreviewed_by += i
	} else {
		m.addreviewed_by = &i
	}
}

// AddedReviewedBy returns the value that was added to the "reviewed_by" field in this mutation.
func (m *UserVerificationsMutation) AddedReviewedBy() (r int64, exists bool) {
	v := m.addreviewed_by
	if v == nil {
		return
	}
	return *v, true
}

// ClearReviewedBy clears the value of the "reviewed_by" field.
func (m *UserVerificationsMutation) ClearReviewedBy() {
	m.reviewed_by = nil
	m.addreviewed_by = nil
	m.clearedFields[userverifications.FieldReviewedBy] = struct{}{}
}

// ReviewedByCleared returns if the "reviewed_by" field was cleared in this mutation.
func (m *UserVerificationsMutation) ReviewedByCleared() bool {
	_, ok := m.clearedFields[userverifications.FieldReviewedBy]
	return ok
}

// ResetReviewedBy resets all changes to the "reviewed_by" field.
func (m *UserVerificationsMutation) ResetReviewedBy() {
	m.reviewed_by = nil
	m.addreviewed_by = nil
	delete(m.clearedFields, userverifications.FieldReviewedBy)
}

// SetReviewedAt sets the "reviewed_at" field.
func (m *UserVerificationsMutation) SetReviewedAt(t time.Time) {
	m.reviewed_at = &t
}

// ReviewedAt returns the value of the "reviewed_at" field in the mutation.
func (m *UserVerificationsMutation) ReviewedAt() (r time.Time, exists bool) {
	v := m.reviewed_at
	if v == nil {
		return
	}
	return *v, true
}

// OldReviewedAt returns the old "reviewed_at" field's value of the UserVerifications entity.
// If the UserVerifications object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserVerificationsMutation) OldReviewedAt(ctx context.Context) (v *time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldReviewedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldReviewedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldReviewedAt: %w", err)
	}
	return oldValue.ReviewedAt, nil
}

// ClearReviewedAt clears the value of the "reviewed_at" field.
func (m *UserVerificationsMutation) ClearReviewedAt() {
	m.reviewed_at = nil
	m.clearedFields[userverifications.FieldReviewedAt] = struct{}{}
}

// ReviewedAtCleared returns if the "reviewed_at" field was cleared in this mutation.
func (m *UserVerificationsMutation) ReviewedAtCleared() bool {
	_, ok := m.clearedFields[userverifications.FieldReviewedAt]
	return ok
}

// ResetReviewedAt resets all changes to the "reviewed_at" field.
func (m *UserVerificationsMutation) ResetReviewedAt() {
	m.reviewed_at = nil
	delete(m.clearedFields, userverifications.FieldReviewedAt)
}

// SetCreatedAt sets the "created_at" field.
func (m *UserVerificationsMutation) SetCreatedAt(t time.Time) {
	m.created_at = &t
}

// CreatedAt returns the value of the "created_at" field in the mutation.
func (m *UserVerificationsMutation) CreatedAt() (r time.Time, exists bool) {
	v := m.created_at
	if v == nil {
		return
	}
	return *v, true
}

// OldCreatedAt returns the old "created_at" field's value of the UserVerifications entity.
// If the UserVerifications object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserVerificationsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldCreatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
	}
	return oldValue.CreatedAt, nil
}

// ClearCreatedAt clears the value of the "created_at" field.
func (m *UserVerificationsMutation) ClearCreatedAt() {
	m.created_at = nil
	m.clearedFields[userverifications.FieldCreatedAt] = struct{}{}
}

// CreatedAtCleared returns if the "created_at" field was cleared in this mutation.
func (m *UserVerificationsMutation) CreatedAtCleared() bool {
	_, ok := m.clearedFields[userverifications.FieldCreatedAt]
	return ok
}

// ResetCreatedAt resets all changes to the "created_at" field.
func (m *UserVerificationsMutation) ResetCreatedAt() {
	m.created_at = nil
	delete(m.clearedFields, userverifications.FieldCreatedAt)
}

// SetUpdatedAt sets the "updated_at" field.
func (m *UserVerificationsMutation) SetUpdatedAt(t time.Time) {
	m.updated_at = &t
}

// UpdatedAt returns the value of the "updated_at" field in the mutation.
func (m *UserVerificationsMutation) UpdatedAt() (r time.Time, exists bool) {
	v := m.updated_at
	if v == nil {
		return
	}
	return *v, true
}

// OldUpdatedAt returns the old "updated_at" field's value of the UserVerifications entity.
// If the UserVerifications object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserVerificationsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
	if !m.op.Is(OpUpdateOne) {
		return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
	}
	if m.id == nil || m.oldValue == nil {
		return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
	}
	oldValue, err := m.oldValue(ctx)
	if err != nil {
		return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
	}
	return oldValue.UpdatedAt, nil
}

// ClearUpdatedAt clears the value of the "updated_at" field.
func (m *UserVerificationsMutation) ClearUpdatedAt() {
	m.updated_at = nil
	m.clearedFields[userverifications.FieldUpdatedAt] = struct{}{}
}

// UpdatedAtCleared returns if the "updated_at" field was cleared in this mutation.
func (m *UserVerificationsMutation) UpdatedAtCleared() bool {
	_, ok := m.clearedFields[userverifications.FieldUpdatedAt]
	return ok
}

// ResetUpdatedAt resets all changes to the "updated_at" field.
func (m *UserVerificationsMutation) ResetUpdatedAt() {
	m.updated_at = nil
	delete(m.clearedFields, userverifications.FieldUpdatedAt)
}

// Where appends a list predicates to the UserVerificationsMutation builder.
func (m *UserVerificationsMutation) Where(ps ...predicate.UserVerifications) {
	m.predicates = append(m.predicates, ps...)
}

// WhereP appends storage-level predicates to the UserVerificationsMutation builder. Using this method,
// users can use type-assertion to append predicates that do not depend on any generated package.
func (m *UserVerificationsMutation) WhereP(ps ...func(*sql.Selector)) {
	p := make([]predicate.UserVerifications, len(ps))
	for i := range ps {
		p[i] = ps[i]
	}
	m.Where(p...)
}

// Op returns the operation name.
func (m *UserVerificationsMutation) Op() Op {
	return m.op
}

// SetOp allows setting the mutation operation.
func (m *UserVerificationsMutation) SetOp(op Op) {
	m.op = op
}

// Type returns the node type of this mutation (UserVerifications).
func (m *UserVerificationsMutation) Type() string {
	return m.typ
}

// Fields returns all fields that were changed during this mutation. Note that in
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *UserVerificationsMutation) Fields() []string {
	fields := make([]string, 0, 9)
	if m.user_id != nil {
		fields = append(fields, userverifications.FieldUserID)
	}
	if m.role != nil {
		fields = append(fields, userverifications.FieldRole)
	}
	if m.status != nil {
		fields = append(fields, userverifications.FieldStatus)
	}
	if m.materials != nil {
		fields = append(fields, userverifications.FieldMaterials)
	}
	if m.reject_reason != nil {
		fields = append(fields, userverifications.FieldRejectReason)
	}
	if m.reviewed_by != nil {
		fields = append(fields, userverifications.FieldReviewedBy)
	}
	if m.reviewed_at != nil {
		fields = append(fields, userverifications.FieldReviewedAt)
	}
	if m.created_at != nil {
		fields = append(fields, userverifications.FieldCreatedAt)
	}
	if m.updated_at != nil {
		fields = append(fields, userverifications.FieldUpdatedAt)
	}
	return fields
}

// Field returns the value of a field with the given name. The second boolean
// return value indicates that this field was not set, or was not defined in the
// schema.
func (m *UserVerificationsMutation) Field(name string) (ent.Value, bool) {
	switch name {
	case userverifications.FieldUserID:
		return m.UserID()
	case userverifications.FieldRole:
		return m.Role()
	case userverifications.FieldStatus:
		return m.Status()
	case userverifications.FieldMaterials:
		return m.Materials()
	case userverifications.FieldRejectReason:
		return m.RejectReason()
	case userverifications.FieldReviewedBy:
		return m.ReviewedBy()
	case userverifications.FieldReviewedAt:
		return m.ReviewedAt()
	case userverifications.FieldCreatedAt:
		return m.CreatedAt()
	case userverifications.FieldUpdatedAt:
		return m.UpdatedAt()
	}
	return nil, false
}

// OldField returns the old value of the field from the database. An error is
// returned if the mutation operation is not UpdateOne, or the query to the
// database failed.
func (m *UserVerificationsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
	switch name {
	case userverifications.FieldUserID:
		return m.OldUserID(ctx)
	case userverifications.FieldRole:
		return m.OldRole(ctx)
	case userverifications.FieldStatus:
		return m.OldStatus(ctx)
	case userverifications.FieldMaterials:
		return m.OldMaterials(ctx)
	case userverifications.FieldRejectReason:
		return m.OldRejectReason(ctx)
	case userverifications.FieldReviewedBy:
		return m.OldReviewedBy(ctx)
	case userverifications.FieldReviewedAt:
		return m.OldReviewedAt(ctx)
	case userverifications.FieldCreatedAt:
		return m.OldCreatedAt(ctx)
	case userverifications.FieldUpdatedAt:
		return m.OldUpdatedAt(ctx)
	}
	return nil, fmt.Errorf("unknown UserVerifications field %s", name)
}

// SetField sets the value of a field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *UserVerificationsMutation) SetField(name string, value ent.Value) error {
	switch name {
	case userverifications.FieldUserID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUserID(v)
		return nil
	case userverifications.FieldRole:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRole(v)
		return nil
	case userverifications.FieldStatus:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetStatus(v)
		return nil
	case userverifications.FieldMaterials:
		v, ok := value.(schema.MaterialStruct)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetMaterials(v)
		return nil
	case userverifications.FieldRejectReason:
		v, ok := value.(string)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetRejectReason(v)
		return nil
	case userverifications.FieldReviewedBy:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetReviewedBy(v)
		return nil
	case userverifications.FieldReviewedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetReviewedAt(v)
		return nil
	case userverifications.FieldCreatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetCreatedAt(v)
		return nil
	case userverifications.FieldUpdatedAt:
		v, ok := value.(time.Time)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.SetUpdatedAt(v)
		return nil
	}
	return fmt.Errorf("unknown UserVerifications field %s", name)
}

// AddedFields returns all numeric fields that were incremented/decremented during
// this mutation.
func (m *UserVerificationsMutation) AddedFields() []string {
	var fields []string
	if m.adduser_id != nil {
		fields = append(fields, userverifications.FieldUserID)
	}
	if m.addreviewed_by != nil {
		fields = append(fields, userverifications.FieldReviewedBy)
	}
	return fields
}

// AddedField returns the numeric value that was incremented/decremented on a field
// with the given name. The second boolean return value indicates that this field
// was not set, or was not defined in the schema.
func (m *UserVerificationsMutation) AddedField(name string) (ent.Value, bool) {
	switch name {
	case userverifications.FieldUserID:
		return m.AddedUserID()
	case userverifications.FieldReviewedBy:
		return m.AddedReviewedBy()
	}
	return nil, false
}

// AddField adds the value to the field with the given name. It returns an error if
// the field is not defined in the schema, or if the type mismatched the field
// type.
func (m *UserVerificationsMutation) AddField(name string, value ent.Value) error {
	switch name {
	case userverifications.FieldUserID:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddUserID(v)
		return nil
	case userverifications.FieldReviewedBy:
		v, ok := value.(int64)
		if !ok {
			return fmt.Errorf("unexpected type %T for field %s", value, name)
		}
		m.AddReviewedBy(v)
		return nil
	}
	return fmt.Errorf("unknown UserVerifications numeric field %s", name)
}

// ClearedFields returns all nullable fields that were cleared during this
// mutation.
func (m *UserVerificationsMutation) ClearedFields() []string {
	var fields []string
	if m.FieldCleared(userverifications.FieldRejectReason) {
		fields = append(fields, userverifications.FieldRejectReason)
	}
	if m.FieldCleared(userverifications.FieldReviewedBy) {
		fields = append(fields, userverifications.FieldReviewedBy)
	}
	if m.FieldCleared(userverifications.FieldReviewedAt) {
		fields = append(fields, userverifications.FieldReviewedAt)
	}
	if m.FieldCleared(userverifications.FieldCreatedAt) {
		fields = append(fields, userverifications.FieldCreatedAt)
	}
	if m.FieldCleared(userverifications.FieldUpdatedAt) {
		fields = append(fields, userverifications.FieldUpdatedAt)
	}
	return fields
}

// FieldCleared returns a boolean indicating if a field with the given name was
// cleared in this mutation.
func (m *UserVerificationsMutation) FieldCleared(name string) bool {
	_, ok := m.clearedFields[name]
	return ok
}

// ClearField clears the value of the field with the given name. It returns an
// error if the field is not defined in the schema.
func (m *UserVerificationsMutation) ClearField(name string) error {
	switch name {
	case userverifications.FieldRejectReason:
		m.ClearRejectReason()
		return nil
	case userverifications.FieldReviewedBy:
		m.ClearReviewedBy()
		return nil
	case userverifications.FieldReviewedAt:
		m.ClearReviewedAt()
		return nil
	case userverifications.FieldCreatedAt:
		m.ClearCreatedAt()
		return nil
	case userverifications.FieldUpdatedAt:
		m.ClearUpdatedAt()
		return nil
	}
	return fmt.Errorf("unknown UserVerifications nullable field %s", name)
}

// ResetField resets all changes in the mutation for the field with the given name.
// It returns an error if the field is not defined in the schema.
func (m *UserVerificationsMutation) ResetField(name string) error {
	switch name {
	case userverifications.FieldUserID:
		m.ResetUserID()
		return nil
	case userverifications.FieldRole:
		m.ResetRole()
		return nil
	case userverifications.FieldStatus:
		m.ResetStatus()
		return nil
	case userverifications.FieldMaterials:
		m.ResetMaterials()
		return nil
	case userverifications.FieldRejectReason:
		m.ResetRejectReason()
		return nil
	case userverifications.FieldReviewedBy:
		m.ResetReviewedBy()
		return nil
	case userverifications.FieldReviewedAt:
		m.ResetReviewedAt()
		return nil
	case userverifications.FieldCreatedAt:
		m.ResetCreatedAt()
		return nil
	case userverifications.FieldUpdatedAt:
		m.ResetUpdatedAt()
		return nil
	}
	return fmt.Errorf("unknown UserVerifications field %s", name)
}

// AddedEdges returns all edge names that were set/added in this mutation.
func (m *UserVerificationsMutation) AddedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// AddedIDs returns all IDs (to other nodes) that were added for the given edge
// name in this mutation.
func (m *UserVerificationsMutation) AddedIDs(name string) []ent.Value {
	return nil
}

// RemovedEdges returns all edge names that were removed in this mutation.
func (m *UserVerificationsMutation) RemovedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
// the given name in this mutation.
func (m *UserVerificationsMutation) RemovedIDs(name string) []ent.Value {
	return nil
}

// ClearedEdges returns all edge names that were cleared in this mutation.
func (m *UserVerificationsMutation) ClearedEdges() []string {
	edges := make([]string, 0, 0)
	return edges
}

// EdgeCleared returns a boolean which indicates if the edge with the given name
// was cleared in this mutation.
func (m *UserVerificationsMutation) EdgeCleared(name string) bool {
	return false
}

// ClearEdge clears the value of the edge with the given name. It returns an error
// if that edge is not defined in the schema.
func (m *UserVerificationsMutation) ClearEdge(name string) error {
	return fmt.Errorf("unknown UserVerifications unique edge %s", name)
}

// ResetEdge resets all changes to the edge with the given name in this mutation.
// It returns an error if the edge is not defined in the schema.
func (m *UserVerificationsMutation) ResetEdge(name string) error {
	return fmt.Errorf("unknown UserVerifications edge %s", name)
}
