Files
MonkeyCode/backend/db/gitbot/gitbot.go
yokowu 34320f9ed5 feat(phase6): 添加 gitbot/gittask 实体 schema 和 migration
- 新增 git_bots, git_bot_users, git_bot_tasks, project_git_bots 表
- 添加 user, host, project 到 gitbot 的关联边
- 使用 soft delete 和 created_at 游标
2026-03-19 18:14:53 +08:00

298 lines
11 KiB
Go

// Code generated by ent, DO NOT EDIT.
package gitbot
import (
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
)
const (
// Label holds the string label denoting the gitbot type in the database.
Label = "git_bot"
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldDeletedAt holds the string denoting the deleted_at field in the database.
FieldDeletedAt = "deleted_at"
// FieldUserID holds the string denoting the user_id field in the database.
FieldUserID = "user_id"
// FieldName holds the string denoting the name field in the database.
FieldName = "name"
// FieldHostID holds the string denoting the host_id field in the database.
FieldHostID = "host_id"
// FieldToken holds the string denoting the token field in the database.
FieldToken = "token"
// FieldSecretToken holds the string denoting the secret_token field in the database.
FieldSecretToken = "secret_token"
// FieldPlatform holds the string denoting the platform field in the database.
FieldPlatform = "platform"
// FieldCreatedAt holds the string denoting the created_at field in the database.
FieldCreatedAt = "created_at"
// EdgeGitBotTasks holds the string denoting the git_bot_tasks edge name in mutations.
EdgeGitBotTasks = "git_bot_tasks"
// EdgeHost holds the string denoting the host edge name in mutations.
EdgeHost = "host"
// EdgeUsers holds the string denoting the users edge name in mutations.
EdgeUsers = "users"
// EdgeProjects holds the string denoting the projects edge name in mutations.
EdgeProjects = "projects"
// EdgeGitBotUsers holds the string denoting the git_bot_users edge name in mutations.
EdgeGitBotUsers = "git_bot_users"
// EdgeProjectGitBots holds the string denoting the project_git_bots edge name in mutations.
EdgeProjectGitBots = "project_git_bots"
// Table holds the table name of the gitbot in the database.
Table = "git_bots"
// GitBotTasksTable is the table that holds the git_bot_tasks relation/edge.
GitBotTasksTable = "git_bot_tasks"
// GitBotTasksInverseTable is the table name for the GitBotTask entity.
// It exists in this package in order to avoid circular dependency with the "gitbottask" package.
GitBotTasksInverseTable = "git_bot_tasks"
// GitBotTasksColumn is the table column denoting the git_bot_tasks relation/edge.
GitBotTasksColumn = "git_bot_id"
// HostTable is the table that holds the host relation/edge.
HostTable = "git_bots"
// 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"
// UsersTable is the table that holds the users relation/edge. The primary key declared below.
UsersTable = "git_bot_users"
// UsersInverseTable is the table name for the User entity.
// It exists in this package in order to avoid circular dependency with the "user" package.
UsersInverseTable = "users"
// ProjectsTable is the table that holds the projects relation/edge. The primary key declared below.
ProjectsTable = "project_git_bots"
// ProjectsInverseTable is the table name for the Project entity.
// It exists in this package in order to avoid circular dependency with the "project" package.
ProjectsInverseTable = "projects"
// GitBotUsersTable is the table that holds the git_bot_users relation/edge.
GitBotUsersTable = "git_bot_users"
// GitBotUsersInverseTable is the table name for the GitBotUser entity.
// It exists in this package in order to avoid circular dependency with the "gitbotuser" package.
GitBotUsersInverseTable = "git_bot_users"
// GitBotUsersColumn is the table column denoting the git_bot_users relation/edge.
GitBotUsersColumn = "git_bot_id"
// ProjectGitBotsTable is the table that holds the project_git_bots relation/edge.
ProjectGitBotsTable = "project_git_bots"
// ProjectGitBotsInverseTable is the table name for the ProjectGitBot entity.
// It exists in this package in order to avoid circular dependency with the "projectgitbot" package.
ProjectGitBotsInverseTable = "project_git_bots"
// ProjectGitBotsColumn is the table column denoting the project_git_bots relation/edge.
ProjectGitBotsColumn = "git_bot_id"
)
// Columns holds all SQL columns for gitbot fields.
var Columns = []string{
FieldID,
FieldDeletedAt,
FieldUserID,
FieldName,
FieldHostID,
FieldToken,
FieldSecretToken,
FieldPlatform,
FieldCreatedAt,
}
var (
// UsersPrimaryKey and UsersColumn2 are the table columns denoting the
// primary key for the users relation (M2M).
UsersPrimaryKey = []string{"user_id", "git_bot_id"}
// ProjectsPrimaryKey and ProjectsColumn2 are the table columns denoting the
// primary key for the projects relation (M2M).
ProjectsPrimaryKey = []string{"project_id", "git_bot_id"}
)
// 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
}
// Note that the variables below are initialized by the runtime
// package on the initialization of the application. Therefore,
// it should be imported in the main as follows:
//
// import _ "github.com/chaitin/MonkeyCode/backend/db/runtime"
var (
Hooks [1]ent.Hook
Interceptors [1]ent.Interceptor
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() time.Time
)
// OrderOption defines the ordering options for the GitBot 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()
}
// ByDeletedAt orders the results by the deleted_at field.
func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
}
// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldUserID, opts...).ToFunc()
}
// ByName orders the results by the name field.
func ByName(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldName, opts...).ToFunc()
}
// ByHostID orders the results by the host_id field.
func ByHostID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldHostID, opts...).ToFunc()
}
// ByToken orders the results by the token field.
func ByToken(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldToken, opts...).ToFunc()
}
// BySecretToken orders the results by the secret_token field.
func BySecretToken(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldSecretToken, opts...).ToFunc()
}
// ByPlatform orders the results by the platform field.
func ByPlatform(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPlatform, opts...).ToFunc()
}
// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}
// ByGitBotTasksCount orders the results by git_bot_tasks count.
func ByGitBotTasksCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newGitBotTasksStep(), opts...)
}
}
// ByGitBotTasks orders the results by git_bot_tasks terms.
func ByGitBotTasks(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newGitBotTasksStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// 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...))
}
}
// ByUsersCount orders the results by users count.
func ByUsersCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newUsersStep(), opts...)
}
}
// ByUsers orders the results by users terms.
func ByUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newUsersStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByProjectsCount orders the results by projects count.
func ByProjectsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newProjectsStep(), opts...)
}
}
// ByProjects orders the results by projects terms.
func ByProjects(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newProjectsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByGitBotUsersCount orders the results by git_bot_users count.
func ByGitBotUsersCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newGitBotUsersStep(), opts...)
}
}
// ByGitBotUsers orders the results by git_bot_users terms.
func ByGitBotUsers(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newGitBotUsersStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
// ByProjectGitBotsCount orders the results by project_git_bots count.
func ByProjectGitBotsCount(opts ...sql.OrderTermOption) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborsCount(s, newProjectGitBotsStep(), opts...)
}
}
// ByProjectGitBots orders the results by project_git_bots terms.
func ByProjectGitBots(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
return func(s *sql.Selector) {
sqlgraph.OrderByNeighborTerms(s, newProjectGitBotsStep(), append([]sql.OrderTerm{term}, terms...)...)
}
}
func newGitBotTasksStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(GitBotTasksInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, GitBotTasksTable, GitBotTasksColumn),
)
}
func newHostStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(HostInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, HostTable, HostColumn),
)
}
func newUsersStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(UsersInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, UsersTable, UsersPrimaryKey...),
)
}
func newProjectsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ProjectsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, ProjectsTable, ProjectsPrimaryKey...),
)
}
func newGitBotUsersStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(GitBotUsersInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, GitBotUsersTable, GitBotUsersColumn),
)
}
func newProjectGitBotsStep() *sqlgraph.Step {
return sqlgraph.NewStep(
sqlgraph.From(Table, FieldID),
sqlgraph.To(ProjectGitBotsInverseTable, FieldID),
sqlgraph.Edge(sqlgraph.O2M, true, ProjectGitBotsTable, ProjectGitBotsColumn),
)
}