File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed
Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ type Book struct {
88 Description string
99 Price int
1010 Rating int
11+ Discount int
1112 CreatedAt time.Time
1213 UpdatedAt time.Time
1314}
Original file line number Diff line number Diff line change 11package main
22
33import (
4- "fmt"
54 "log"
65 "net/http"
76
7+ "pustaka-api/book"
88 "pustaka-api/handler"
99
1010 "github.com/gin-gonic/gin"
@@ -16,13 +16,14 @@ import (
1616func main () {
1717 // refer https://github.com/go-sql-driver/mysql#dsn-data-source-name for details
1818 dsn := "root:@tcp(127.0.0.1:3306)/pustaka-api?charset=utf8mb4&parseTime=True&loc=Local"
19- _ , err := gorm .Open (mysql .Open (dsn ), & gorm.Config {})
19+ db , err := gorm .Open (mysql .Open (dsn ), & gorm.Config {})
2020
2121 if err != nil {
2222 log .Fatal ("Db Erorr" )
2323 }
2424
25- fmt .Println ("Database Berhasil Terhubung" )
25+ //fmt.Println("Database Berhasil Terhubung")
26+ db .AutoMigrate (& book.Book {})
2627
2728 router := gin .Default ()
2829
You can’t perform that action at this time.
0 commit comments