Files
yokowu c30c73aa93 feat: 添加 Host/VM ent schema 和数据库迁移
- ent/schema: host, virtualmachine, teamhost, teamgrouphost
- 修改 user/team/teamgroup/model schema 添加 host/vm edges
- migration/000003: hosts, virtualmachines, team_hosts, team_group_hosts 建表
2026-03-17 14:38:26 +08:00

118 lines
3.7 KiB
Go

// Code generated by ent, DO NOT EDIT.
package teamhost
import (
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the teamhost type in the database.
Label = "team_host"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldTeamID holds the string denoting the team_id field in the database.
FieldTeamID = "team_id"
// FieldHostID holds the string denoting the host_id field in the database.
FieldHostID = "host_id"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// EdgeTeam holds the string denoting the team edge name in mutations.
EdgeTeam = "team"
// EdgeHost holds the string denoting the host edge name in mutations.
EdgeHost = "host"
// Table holds the table name of the teamhost in the database.
Table = "team_hosts"
// TeamTable is the table that holds the team relation/edge.
TeamTable = "team_hosts"
// TeamInverseTable is the table name for the Team entity.
// It exists in this package in order to avoid circular dependency with the "team" package.
TeamInverseTable = "teams"
// TeamColumn is the table column denoting the team relation/edge.
TeamColumn = "team_id"
// HostTable is the table that holds the host relation/edge.
HostTable = "team_hosts"
// HostInverseTable is the table name for the Host entity.
// It exists in this package in order to avoid circular dependency with the "host" package.
HostInverseTable = "hosts"
// HostColumn is the table column denoting the host relation/edge.
HostColumn = "host_id"
)
// Columns holds all SQL columns for teamhost fields.
var Columns = []string{
FieldID,
FieldTeamID,
FieldHostID,
FieldCreatedAt,
}
// 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 "created_at" field.
DefaultCreatedAt func() time.Time
)
// OrderOption defines the ordering options for the TeamHost 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()
}
// ByTeamID orders the results by the team_id field.
func ByTeamID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTeamID, opts...).ToFunc()
}
// ByHostID orders the results by the host_id field.
func ByHostID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldHostID, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByTeamField orders the results by team field.
func ByTeamField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newTeamStep(), sql.OrderByField(field, opts...))
}
}
// ByHostField orders the results by host field.
func ByHostField(field string, opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newHostStep(), sql.OrderByField(field, opts...))
}
}
func newTeamStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(TeamInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, TeamTable, TeamColumn),
)
}
func newHostStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(HostInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, false, HostTable, HostColumn),
)
}