pomme/internal/db/db.go

23 lines
453 B
Go

package db
import (
"git.freecumextremist.com/grumbulon/pomme/internal"
"github.com/glebarez/sqlite"
"gorm.io/gorm"
)
// InitDb is the init function for the database.
func InitDb() *gorm.DB {
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
// Migrate the schema
err = db.AutoMigrate(&internal.User{})
if err != nil {
panic("failed to run DB migration")
}
return db
}