Skip to content

Commit

Permalink
added new cmd command for create a new migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Zatonskiy committed Aug 1, 2023
1 parent d82b676 commit 231bfee
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions internal/command/migrate_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ func NewMigrateCreate(ctn di.Container) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
return ctn.Call(func(ctx context.Context, logger *zap.Logger) (err error) {
var (
name = args[0]
path = cmd.Flag("path").Value.String()
name = args[0]
path = cmd.Flag("path").Value.String()
fileName string
)
if !filepath.IsAbs(path) {
var appPath, ok = ctx.Value("app.path").(string)
Expand All @@ -46,14 +47,11 @@ func NewMigrateCreate(ctn di.Container) *cobra.Command {
path = filepath.Join(appPath, path)
}

if _, err = create(path, name, migrationFileExtension); err != nil {
if fileName, err = create(path, name, migrationFileExtension); err != nil {
return err
}

logger.Info(
"Created migration",
zap.String("migration", filepath.Join(path, name+"."+migrationFileExtension)),
)
logger.Info("Created migration", zap.String("migration", fileName))

return nil
})
Expand Down

0 comments on commit 231bfee

Please sign in to comment.