Skip to content

Commit

Permalink
perf: add migrating migrations before running app.
Browse files Browse the repository at this point in the history
  • Loading branch information
just-pthai-it committed Aug 25, 2024
1 parent ff263a1 commit d04056b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,28 @@ import (
_ "UTCTSS-microservices/docs"
"fmt"
"github.com/gin-gonic/gin"
"log"
"os/exec"
)

func main() {
router := gin.Default()
migrateCmd := exec.Command("./build/migrationtool", "./database/migrations/", "up")
output, err := migrateCmd.CombinedOutput()
if err != nil {
log.Fatal(err)
}
fmt.Println("Migrate successful!")
fmt.Println(string(output))

router := gin.Default()
router.Use(middlewares.ConsoleLoggerMiddleware)
router.Use(middlewares.FileLoggerMiddleware)
router.Use(middlewares.GinLoggerCustomFormat())

routes.NewApiRoutes(router)

// Run the server on port 8080
err := router.Run(":8080")
err = router.Run(":8080")
if err != nil {
fmt.Println(err)
return
Expand Down

0 comments on commit d04056b

Please sign in to comment.