// Code generated by ent, DO NOT EDIT.

package projectversion

import (
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
	"github.com/google/uuid"
)

const (
	// Label holds the string label denoting the projectversion type in the database.
	Label = "project_version"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldVersion holds the string denoting the version field in the database.
	FieldVersion = "version"
	// FieldCreatedAt holds the string denoting the created_at field in the database.
	FieldCreatedAt = "created_at"
	// FieldUpdatedAt holds the string denoting the updated_at field in the database.
	FieldUpdatedAt = "updated_at"
	// FieldDeletedAt holds the string denoting the deleted_at field in the database.
	FieldDeletedAt = "deleted_at"
	// FieldProjectID holds the string denoting the project_id field in the database.
	FieldProjectID = "project_id"
	// FieldPrerelease holds the string denoting the prerelease field in the database.
	FieldPrerelease = "prerelease"
	// FieldWorkflowRunCount holds the string denoting the workflow_run_count field in the database.
	FieldWorkflowRunCount = "workflow_run_count"
	// FieldReleasedAt holds the string denoting the released_at field in the database.
	FieldReleasedAt = "released_at"
	// FieldLastRunAt holds the string denoting the last_run_at field in the database.
	FieldLastRunAt = "last_run_at"
	// FieldLatest holds the string denoting the latest field in the database.
	FieldLatest = "latest"
	// EdgeProject holds the string denoting the project edge name in mutations.
	EdgeProject = "project"
	// EdgeRuns holds the string denoting the runs edge name in mutations.
	EdgeRuns = "runs"
	// Table holds the table name of the projectversion in the database.
	Table = "project_versions"
	// ProjectTable is the table that holds the project relation/edge.
	ProjectTable = "project_versions"
	// ProjectInverseTable is the table name for the Project entity.
	// It exists in this package in order to avoid circular dependency with the "project" package.
	ProjectInverseTable = "projects"
	// ProjectColumn is the table column denoting the project relation/edge.
	ProjectColumn = "project_id"
	// RunsTable is the table that holds the runs relation/edge.
	RunsTable = "workflow_runs"
	// RunsInverseTable is the table name for the WorkflowRun entity.
	// It exists in this package in order to avoid circular dependency with the "workflowrun" package.
	RunsInverseTable = "workflow_runs"
	// RunsColumn is the table column denoting the runs relation/edge.
	RunsColumn = "version_id"
)

// Columns holds all SQL columns for projectversion fields.
var Columns = []string{
	FieldID,
	FieldVersion,
	FieldCreatedAt,
	FieldUpdatedAt,
	FieldDeletedAt,
	FieldProjectID,
	FieldPrerelease,
	FieldWorkflowRunCount,
	FieldReleasedAt,
	FieldLastRunAt,
	FieldLatest,
}

// 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 (
	// DefaultVersion holds the default value on creation for the "version" field.
	DefaultVersion string
	// VersionValidator is a validator for the "version" field. It is called by the builders before save.
	VersionValidator func(string) error
	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
	DefaultCreatedAt func() time.Time
	// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
	DefaultUpdatedAt func() time.Time
	// DefaultPrerelease holds the default value on creation for the "prerelease" field.
	DefaultPrerelease bool
	// DefaultWorkflowRunCount holds the default value on creation for the "workflow_run_count" field.
	DefaultWorkflowRunCount int
	// DefaultLatest holds the default value on creation for the "latest" field.
	DefaultLatest bool
	// DefaultID holds the default value on creation for the "id" field.
	DefaultID func() uuid.UUID
)

// OrderOption defines the ordering options for the ProjectVersion queries.
type OrderOption func(*sql.Selector)

// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldID, opts...).ToFunc()
}

// ByVersion orders the results by the version field.
func ByVersion(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldVersion, opts...).ToFunc()
}

// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}

// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}

// ByDeletedAt orders the results by the deleted_at field.
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
}

// ByProjectID orders the results by the project_id field.
func ByProjectID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldProjectID, opts...).ToFunc()
}

// ByPrerelease orders the results by the prerelease field.
func ByPrerelease(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPrerelease, opts...).ToFunc()
}

// ByWorkflowRunCount orders the results by the workflow_run_count field.
func ByWorkflowRunCount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldWorkflowRunCount, opts...).ToFunc()
}

// ByReleasedAt orders the results by the released_at field.
func ByReleasedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldReleasedAt, opts...).ToFunc()
}

// ByLastRunAt orders the results by the last_run_at field.
func ByLastRunAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLastRunAt, opts...).ToFunc()
}

// ByLatest orders the results by the latest field.
func ByLatest(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldLatest, opts...).ToFunc()
}

// ByProjectField orders the results by project field.
func ByProjectField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newProjectStep(), sql.OrderByField(field, opts...))
	}
}

// ByRunsCount orders the results by runs count.
func ByRunsCount(opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborsCount(s, newRunsStep(), opts...)
	}
}

// ByRuns orders the results by runs terms.
func ByRuns(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newRunsStep(), append([]sql.OrderTerm{term}, terms...)...)
	}
}
func newProjectStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(ProjectInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, ProjectTable, ProjectColumn),
	)
}
func newRunsStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(RunsInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.O2M, false, RunsTable, RunsColumn),
	)
}
