midr @ 68b27b6b0376458eaa19b25e0058d8a5249cd65c

 1package db
 2
 3import (
 4	"path"
 5
 6	"gorm.io/driver/sqlite"
 7	"gorm.io/gorm"
 8)
 9
10var (
11	DB  *gorm.DB
12	err error
13)
14
15func ConnectDb(folder string) {
16	dbPath := path.Join(folder, "main.db")
17
18	DB, err = gorm.Open(sqlite.Open(dbPath), &gorm.Config{})
19
20	if err != nil {
21		panic("failed to connect to the database.")
22	}
23
24	DB.AutoMigrate(&Entry{})
25}