add user model / service and database maintenance command
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/mayswind/lab/pkg/datastore"
|
||||
"github.com/mayswind/lab/pkg/log"
|
||||
"github.com/mayswind/lab/pkg/models"
|
||||
)
|
||||
|
||||
var Database = cli.Command{
|
||||
Name: "database",
|
||||
Usage: "lab database maintenance",
|
||||
Subcommands: []cli.Command{
|
||||
{
|
||||
Name: "update",
|
||||
Usage: "Update database structure",
|
||||
Action: updateDatabaseStructure,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func updateDatabaseStructure(c *cli.Context) error {
|
||||
_, err := initializeSystem(c)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
log.BootInfof("[database.updateDatabaseStructure] starting maintaining")
|
||||
|
||||
_ = datastore.Container.UserStore.SyncStructs(new(models.User))
|
||||
|
||||
log.BootInfof("[database.updateDatabaseStructure] maintained successfully")
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user