Documentation
¶
Overview ¶
Package make 命令行的 make 命令.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrDDLDiffFound = errors.New("ddl drift detected")
ErrDDLDiffFound 表示当前模型生成的 DDL 与已落盘文件存在漂移。
Functions ¶
func GenerateCreateTableDDL ¶
GenerateCreateTableDDL 基于 GORM dry-run 输出严格的建表 SQL。
func NewCommand ¶
NewCommand 构建 make 命令树,base 为生成配置(零值字段回退到内置默认值). 返回的命令树持有自身配置副本,多次调用互不影响.
Types ¶
type Config ¶
type Config struct {
ProjectName string
ModelDir string
RepositoryDir string
MigrationDir string
DDLDir string
CmdDir string
DB *gorm.DB
DDLModels []any
}
Config 控制 make 系列命令的生成目录和 DDL 上下文。
type Model ¶
type Model struct {
TableName string
StructName string
StructNamePlural string
StructFieldName string
VariableName string
VariableNamePlural string
PackageName string
ActionName string
ProjectName string
ColumnName string
ModelPackageName string
ModelsImportPath string
DbtxImportPath string
}
Model 参数解释
单个词,以 User 模型为例:
{
"TableName": "users",
"StructName": "User",
"StructNamePlural": "Users",
"VariableName": "user",
"VariableNamePlural": "users",
"PackageName": "user"
}
两个词以上,以 TopicComment 模型为例:
{
"TableName": "topic_comments",
"StructName": "TopicComment",
"StructNamePlural": "TopicComments",
"VariableName": "topicComment",
"VariableNamePlural": "topicComments",
"PackageName": "topic_comment"
}
Click to show internal directories.
Click to hide internal directories.