// Code generated by entc, DO NOT EDIT.

package triage

import (
	"fmt"
	"time"

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

const (
	// Label holds the string label denoting the triage type in the database.
	Label = "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"
	// FieldTriagingUsers holds the string denoting the triagingusers field in the database.
	FieldTriagingUsers = "triaging_users"
	// FieldToTriageCaseExecIDs holds the string denoting the totriagecaseexecids field in the database.
	FieldToTriageCaseExecIDs = "to_triage_case_exec_ids"
	// FieldTriagedCaseExecIDs holds the string denoting the triagedcaseexecids field in the database.
	FieldTriagedCaseExecIDs = "triaged_case_exec_ids"
	// FieldTriagePhase holds the string denoting the triagephase field in the database.
	FieldTriagePhase = "triage_phase"
	// FieldStartedAt holds the string denoting the startedat field in the database.
	FieldStartedAt = "started_at"
	// FieldTriagedAt holds the string denoting the triagedat field in the database.
	FieldTriagedAt = "triaged_at"
	// FieldReasons holds the string denoting the reasons field in the database.
	FieldReasons = "reasons"
	// FieldSolution holds the string denoting the solution field in the database.
	FieldSolution = "solution"
	// FieldNote holds the string denoting the note field in the database.
	FieldNote = "note"
	// Table holds the table name of the triage in the database.
	Table = "triages"
)

// Columns holds all SQL columns for triage fields.
var Columns = []string{
	FieldID,
	FieldCreatedAt,
	FieldUpdatedAt,
	FieldPlanExecutionID,
	FieldPlanID,
	FieldTriagingUsers,
	FieldToTriageCaseExecIDs,
	FieldTriagedCaseExecIDs,
	FieldTriagePhase,
	FieldStartedAt,
	FieldTriagedAt,
	FieldReasons,
	FieldSolution,
	FieldNote,
}

// 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
	// DefaultTriagingUsers holds the default value on creation for the "triagingUsers" field.
	DefaultTriagingUsers []model.ID
	// DefaultToTriageCaseExecIDs holds the default value on creation for the "toTriageCaseExecIDs" field.
	DefaultToTriageCaseExecIDs []model.ID
	// DefaultTriagedCaseExecIDs holds the default value on creation for the "triagedCaseExecIDs" field.
	DefaultTriagedCaseExecIDs []model.ID
	// DefaultReasons holds the default value on creation for the "reasons" field.
	DefaultReasons []model.CaseExecFailReason
	// 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
)

const DefaultTriagePhase model.TriagePhase = "TO_TRIAGE"

// TriagePhaseValidator is a validator for the "triagePhase" field enum values. It is called by the builders before save.
func TriagePhaseValidator(tp model.TriagePhase) error {
	switch tp {
	case "TO_TRIAGE", "TRIAGING", "TRIAGED":
		return nil
	default:
		return fmt.Errorf("triage: invalid enum value for triagePhase field: %q", tp)
	}
}

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("triage: invalid enum value for solution field: %q", s)
	}
}
