Skip to content

Commit

Permalink
fix: cli数据库迁移
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Dec 29, 2024
1 parent 40d6b2c commit cff8925
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cmd/cli/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions internal/app/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ import (
"context"
"os"

"github.com/go-gormigrate/gormigrate/v2"
"github.com/urfave/cli/v3"
)

type Cli struct {
cmd *cli.Command
cmd *cli.Command
migrator *gormigrate.Gormigrate
}

func NewCli(cmd *cli.Command) *Cli {
func NewCli(cmd *cli.Command, migrator *gormigrate.Gormigrate) *Cli {
IsCli = true
return &Cli{
cmd: cmd,
cmd: cmd,
migrator: migrator,
}
}

func (r *Cli) Run() error {
// migrate database
if err := r.migrator.Migrate(); err != nil {
return err
}

return r.cmd.Run(context.Background(), os.Args)
}

0 comments on commit cff8925

Please sign in to comment.