-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
66 lines (57 loc) · 1.87 KB
/
main.go
File metadata and controls
66 lines (57 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"github.com/anthonyhawkins/savorbook/database"
"github.com/anthonyhawkins/savorbook/images"
"github.com/anthonyhawkins/savorbook/publish/cookbooks"
"github.com/anthonyhawkins/savorbook/publish/recipes"
"github.com/anthonyhawkins/savorbook/router"
"github.com/anthonyhawkins/savorbook/users"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
"gorm.io/gorm"
)
func Migrate(db *gorm.DB) {
/* db.Migrator().DropTable(&cookbooks.CookbookModel{})
db.Migrator().DropTable(&cookbooks.SectionModel{})
db.Migrator().DropTable(&recipes.RecipeModel{})
db.Migrator().DropTable(&recipes.TagModel{})
type RecipeTags struct {
}
db.Migrator().DropTable(&RecipeTags{})
db.Migrator().DropTable(&recipes.IngredientGroupModel{})
db.Migrator().DropTable(&recipes.IngredientModel{})
db.Migrator().DropTable(&recipes.StepModel{})
db.Migrator().DropTable(&recipes.StepImageModel{})
db.Migrator().DropTable(&recipes.RecipeDependencyModel{})
*/
//db.Migrator().DropTable(&users.UserModel{})
db.AutoMigrate(&users.UserModel{})
db.AutoMigrate(&recipes.RecipeModel{})
db.AutoMigrate(&recipes.TagModel{})
db.AutoMigrate(&recipes.IngredientGroupModel{})
db.AutoMigrate(&recipes.IngredientModel{})
db.AutoMigrate(&recipes.StepModel{})
db.AutoMigrate(&recipes.StepImageModel{})
db.AutoMigrate(&recipes.RecipeDependencyModel{})
db.AutoMigrate(&images.Image{})
db.AutoMigrate(&cookbooks.CookbookModel{})
db.AutoMigrate(&cookbooks.SectionModel{})
}
func main() {
db := database.Init()
Migrate(db)
sqlDB := database.GetSqlDB(db)
defer sqlDB.Close()
app := fiber.New(fiber.Config{
Prefork: true,
CaseSensitive: true,
StrictRouting: true,
ServerHeader: "Fiber",
BodyLimit: 4194304,
})
app.Use(logger.New())
app.Use(cors.New())
router.SetupRoutes(app)
app.Listen(":3000")
}