Files
bamort/backend/maintenance/handlers.go
T

59 lines
1.6 KiB
Go
Raw Normal View History

2025-01-03 15:50:56 +01:00
package maintenance
2025-01-02 21:42:20 +01:00
import (
"bamort/character"
"bamort/database"
"bamort/equipment"
"bamort/gsmaster"
"bamort/importer"
"bamort/skills"
"bamort/user"
"net/http"
"github.com/gin-gonic/gin"
)
func SetupCheck(c *gin.Context) {
db := database.ConnectDatabase()
2025-01-03 15:50:56 +01:00
if db == nil {
2025-01-02 21:42:20 +01:00
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to connect to DataBase"})
return
}
2025-01-18 20:59:54 +01:00
err := database.MigrateStructure()
2025-01-02 21:42:20 +01:00
if err != nil {
2025-01-18 20:59:54 +01:00
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to automigrate database DataBase"})
2025-01-02 21:42:20 +01:00
return
}
2025-01-18 20:59:54 +01:00
err = user.MigrateStructure()
2025-01-02 21:42:20 +01:00
if err != nil {
2025-01-18 20:59:54 +01:00
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to automigrate user DataBase"})
return
2025-01-02 21:42:20 +01:00
}
err = character.MigrateStructure()
if err != nil {
2025-01-18 20:59:54 +01:00
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to automigratec haracter DataBase"})
return
2025-01-02 21:42:20 +01:00
}
err = gsmaster.MigrateStructure()
if err != nil {
2025-01-18 20:59:54 +01:00
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to automigrate gsmaster DataBase"})
return
2025-01-02 21:42:20 +01:00
}
2025-01-03 15:50:56 +01:00
err = equipment.MigrateStructure()
2025-01-02 21:42:20 +01:00
if err != nil {
2025-01-18 20:59:54 +01:00
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to automigrate equipment DataBase"})
return
2025-01-02 21:42:20 +01:00
}
err = skills.MigrateStructure()
if err != nil {
2025-01-18 20:59:54 +01:00
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to automigrate skills DataBase"})
return
2025-01-02 21:42:20 +01:00
}
2025-01-03 15:50:56 +01:00
err = importer.MigrateStructure()
2025-01-02 21:42:20 +01:00
if err != nil {
2025-01-18 20:59:54 +01:00
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to automigrate importer DataBase"})
return
2025-01-02 21:42:20 +01:00
}
2025-01-18 20:59:54 +01:00
c.JSON(http.StatusOK, gin.H{"message": "Setup Check OK"})
2025-01-02 21:42:20 +01:00
}