mirror of
https://github.com/IllusionMan1212/gorc.git
synced 2026-10-24 02:12:33 +00:00
WIP: offloading to disk
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
)
|
||||
|
||||
type History struct {
|
||||
Hash string `gorm:"index"`
|
||||
Line uint64 `gorm:"index" gorm:"unique"`
|
||||
Message string
|
||||
}
|
||||
|
||||
func ConnectToDB() (*gorm.DB, error) {
|
||||
db, err := gorm.Open(sqlite.Open("gorc.db"), &gorm.Config{
|
||||
Logger: logger.Default.LogMode(logger.Silent),
|
||||
AllowGlobalUpdate: true,
|
||||
})
|
||||
|
||||
db.AutoMigrate(&History{})
|
||||
db.Delete(&History{})
|
||||
|
||||
return db, err
|
||||
}
|
||||
Reference in New Issue
Block a user