Init: bootstrap go module with basic framework

This commit is contained in:
2025-09-25 08:14:34 +08:00
commit 60f534be1e
47 changed files with 1084 additions and 0 deletions

33
cmd/migrates/up.go Normal file
View File

@@ -0,0 +1,33 @@
package migrates
import (
"fmt"
"github.com/spf13/cobra"
)
var upCmd = &cobra.Command{
Use: "up",
Short: "migrate up",
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
if err := migrator.Lock(ctx); err != nil {
return err
}
defer migrator.Unlock(ctx)
group, err := migrator.Migrate(ctx)
if err != nil {
return err
}
if group.IsZero() {
fmt.Printf("there are no new migrations to run\n")
return nil
}
fmt.Printf("migrated to %s\n", group)
return nil
},
}