// Code generated by entc, DO NOT EDIT.

package resourceduration

import (
	"fmt"
	"time"

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

const (
	// Label holds the string label denoting the resourceduration type in the database.
	Label = "resource_duration"
	// 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"
	// FieldType holds the string denoting the type field in the database.
	FieldType = "type"
	// FieldCpuDuration holds the string denoting the cpuduration field in the database.
	FieldCpuDuration = "cpu_duration"
	// FieldMemoryDuration holds the string denoting the memoryduration field in the database.
	FieldMemoryDuration = "memory_duration"
	// Table holds the table name of the resourceduration in the database.
	Table = "resource_durations"
)

// Columns holds all SQL columns for resourceduration fields.
var Columns = []string{
	FieldID,
	FieldCreatedAt,
	FieldUpdatedAt,
	FieldPlanExecutionID,
	FieldType,
	FieldCpuDuration,
	FieldMemoryDuration,
}

// 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
)

const DefaultType model.ResourceDurationType = "PREPARE_ERROR"

// TypeValidator is a validator for the "type" field enum values. It is called by the builders before save.
func TypeValidator(_type model.ResourceDurationType) error {
	switch _type {
	case "PREPARE_ERROR", "PREPARE", "RUNNING", "WAIT_TRIAGE", "TRIAGE":
		return nil
	default:
		return fmt.Errorf("resourceduration: invalid enum value for type field: %q", _type)
	}
}
