generated from schreifuchs/wails-template
37 lines
497 B
Go
37 lines
497 B
Go
package model
|
|
|
|
import (
|
|
"log"
|
|
|
|
"gorm.io/driver/sqlite"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func InitDB() *gorm.DB {
|
|
db, err := gorm.Open(sqlite.Open("tournament.db"))
|
|
if err != nil {
|
|
log.Panic(err)
|
|
}
|
|
db.AutoMigrate(&Game{}, &Participant{}, &Tournament{}, &Match{})
|
|
db.Save(&Game{
|
|
Model: gorm.Model{
|
|
ID: 1,
|
|
},
|
|
Name: "CS:GO",
|
|
})
|
|
db.Save(&Game{
|
|
Model: gorm.Model{
|
|
ID: 2,
|
|
},
|
|
Name: "Overwatch",
|
|
})
|
|
db.Save(&Game{
|
|
Model: gorm.Model{
|
|
ID: 3,
|
|
},
|
|
Name: "Minecraft",
|
|
})
|
|
|
|
return db
|
|
}
|