mirror of
https://git.freecumextremist.com/grumbulon/pomme.git
synced 2024-12-23 10:30:43 +00:00
23 lines
482 B
Go
23 lines
482 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.sqlite"), &gorm.Config{})
|
|
if err != nil {
|
|
panic("failed to connect database")
|
|
}
|
|
|
|
// Migrate the schema
|
|
err = db.AutoMigrate(&internal.User{}, &internal.ZoneRequest{})
|
|
if err != nil {
|
|
panic("failed to run DB migration")
|
|
}
|
|
|
|
return db
|
|
}
|