Fixed database setup; finished item creation form

This commit is contained in:
2022-12-08 00:19:58 -05:00
parent ec78e5e1ae
commit ca6e14bcb5
6 changed files with 85 additions and 5 deletions

View File

@ -6,15 +6,17 @@ import (
)
var (
DB gorm.DB
DB *gorm.DB
)
func InitDatabase() {
DB, err := gorm.Open(sqlite.Open("data/raven.db"), &gorm.Config{})
database, err := gorm.Open(sqlite.Open("data/raven.db"), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
// Migrate the schema
DB.AutoMigrate(&Item{})
database.AutoMigrate(&Item{})
DB = database
}