// Code generated by entc, DO NOT EDIT.

package casetriage

import (
	"fmt"
	"time"

	"github.com/pingcap/test-infra/common/model"
)

const (
	// Label holds the string label denoting the casetriage type in the database.
	Label = "case_triage"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldCreatedAt holds the string denoting the createdat field in the database.
	FieldCreatedAt = "created_at"
	// FieldUpdatedAt holds the string denoting the updatedat field in the database.
	FieldUpdatedAt = "updated_at"
	// FieldPlanExecutionID holds the string denoting the planexecutionid field in the database.
	FieldPlanExecutionID = "plan_execution_id"
	// FieldPlanID holds the string denoting the planid field in the database.
	FieldPlanID = "plan_id"
	// FieldCaseExecutionID holds the string denoting the caseexecutionid field in the database.
	FieldCaseExecutionID = "case_execution_id"
	// FieldCaseID holds the string denoting the caseid field in the database.
	FieldCaseID = "case_id"
	// FieldReason holds the string denoting the reason field in the database.
	FieldReason = "reason"
	// FieldSolution holds the string denoting the solution field in the database.
	FieldSolution = "solution"
	// FieldIssueLink holds the string denoting the issuelink field in the database.
	FieldIssueLink = "issue_link"
	// FieldNote holds the string denoting the note field in the database.
	FieldNote = "note"
	// FieldForkedFrom holds the string denoting the forkedfrom field in the database.
	FieldForkedFrom = "forked_from"
	// Table holds the table name of the casetriage in the database.
	Table = "case_triages"
)

// Columns holds all SQL columns for casetriage fields.
var Columns = []string{
	FieldID,
	FieldCreatedAt,
	FieldUpdatedAt,
	FieldPlanExecutionID,
	FieldPlanID,
	FieldCaseExecutionID,
	FieldCaseID,
	FieldReason,
	FieldSolution,
	FieldIssueLink,
	FieldNote,
	FieldForkedFrom,
}

// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
	for i := range Columns {
		if column == Columns[i] {
			return true
		}
	}
	return false
}

var (
	// DefaultCreatedAt holds the default value on creation for the "createdAt" field.
	DefaultCreatedAt func() time.Time
	// DefaultUpdatedAt holds the default value on creation for the "updatedAt" field.
	DefaultUpdatedAt func() time.Time
	// UpdateDefaultUpdatedAt holds the default value on update for the "updatedAt" field.
	UpdateDefaultUpdatedAt func() time.Time
	// PlanExecutionIDValidator is a validator for the "planExecutionID" field. It is called by the builders before save.
	PlanExecutionIDValidator func(uint64) error
	// PlanIDValidator is a validator for the "planID" field. It is called by the builders before save.
	PlanIDValidator func(uint64) error
	// CaseExecutionIDValidator is a validator for the "caseExecutionID" field. It is called by the builders before save.
	CaseExecutionIDValidator func(uint64) error
	// CaseIDValidator is a validator for the "caseID" field. It is called by the builders before save.
	CaseIDValidator func(uint64) error
	// DefaultIssueLink holds the default value on creation for the "issueLink" field.
	DefaultIssueLink string
	// IssueLinkValidator is a validator for the "issueLink" field. It is called by the builders before save.
	IssueLinkValidator func(string) error
	// DefaultNote holds the default value on creation for the "note" field.
	DefaultNote string
	// NoteValidator is a validator for the "note" field. It is called by the builders before save.
	NoteValidator func(string) error
	// DefaultForkedFrom holds the default value on creation for the "forkedFrom" field.
	DefaultForkedFrom model.ID
)

const DefaultReason model.CaseExecFailReason = "CASE"

// ReasonValidator is a validator for the "reason" field enum values. It is called by the builders before save.
func ReasonValidator(r model.CaseExecFailReason) error {
	switch r {
	case "CASE", "PRODUCT", "ENV":
		return nil
	default:
		return fmt.Errorf("casetriage: invalid enum value for reason field: %q", r)
	}
}

const DefaultSolution model.ExecFailSolution = "KEEP"

// SolutionValidator is a validator for the "solution" field enum values. It is called by the builders before save.
func SolutionValidator(s model.ExecFailSolution) error {
	switch s {
	case "KEEP", "FIX", "PAUSE", "STOP":
		return nil
	default:
		return fmt.Errorf("casetriage: invalid enum value for solution field: %q", s)
	}
}
