Added models; started working on project routes

This commit is contained in:
2023-11-27 23:41:48 -05:00
parent 49925c6d8f
commit 19670e9abd
8 changed files with 131 additions and 2 deletions

View File

@ -7,14 +7,18 @@ import (
"gorm.io/driver/sqlite"
)
var (
DB *gorm.DB
)
func InitDatabase() {
// Initialize database object
db, err := gorm.Open(sqlite.Open("data/blt.db"), &gorm.Config{})
DB, err := gorm.Open(sqlite.Open("data/blt.db"), &gorm.Config{})
if err != nil {
panic("Failed to connect database")
}
// Migrate the schema
db.AutoMigrate(&Project{})
DB.AutoMigrate(&Project{}, &Hardware{}, &Benchmark{})
log.Println("Database migrations complete.")
}