feat: 增强命令帮助文档,添加详细说明和示例

This commit is contained in:
Rogee
2025-09-12 10:33:57 +08:00
parent a96df4d628
commit ee15e0932a
17 changed files with 217 additions and 52 deletions

View File

@@ -17,6 +17,20 @@ func CommandMigrate(root *cobra.Command) {
Use: "migrate [up|up-by-one|up-to|create|down|down-to|fix|redo|reset|status|version]",
Aliases: []string{"m"},
RunE: commandMigrate,
Long: `基于 goose 的数据库迁移工具。
action
up|up-by-one|up-to|create|down|down-to|fix|redo|reset|status|version
参数:
-c, --config 数据库配置文件(默认 config.toml读取 [Database]
--dir 迁移目录(默认 database/migrations
--table 迁移版本表名(默认 migrations
说明:
- 执行 create 时会在缺省情况下追加 sql 类型
- 使用配置连接数据库,并通过 goose.Run 执行对应 action
- 可在代码中通过 goose.SetTableName 自定义版本表名`,
}
cmd.Flags().StringP("config", "c", "config.toml", "database config file")
cmd.Flags().String("dir", "database/migrations", "migrations directory")