mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2025-05-27 13:53:14 +00:00
Add migration, status and pending checks to database
This commit is contained in:
parent
b2933a41c1
commit
66fb03fa0d
9 changed files with 146 additions and 42 deletions
16
cmd/run.go
16
cmd/run.go
|
@ -6,12 +6,14 @@ import (
|
|||
"os"
|
||||
|
||||
"github.com/Fluffy-Bean/TastyBites/api"
|
||||
db "github.com/Fluffy-Bean/TastyBites/database"
|
||||
)
|
||||
|
||||
func run(flags []string) {
|
||||
cmd := flag.NewFlagSet("run", flag.ExitOnError)
|
||||
|
||||
host := cmd.String("host", "127.0.0.1:8080", "Host address, such as 0.0.0.0:8080")
|
||||
skip := cmd.Bool("skipMigrations", false, "Skip any pending migrations")
|
||||
logging := cmd.Bool("log", false, "Enable logging for the application")
|
||||
|
||||
err := cmd.Parse(flags)
|
||||
|
@ -20,6 +22,20 @@ func run(flags []string) {
|
|||
os.Exit(1)
|
||||
}
|
||||
|
||||
if !*skip {
|
||||
pending, err := db.Pending()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if pending {
|
||||
fmt.Println("Pending migrations!")
|
||||
fmt.Println("Run `TastyBites status` or use the flag -skipMigrations")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
api.Serve(api.Config{
|
||||
Host: *host,
|
||||
Logging: *logging,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue