mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-11-13 14:45:27 +00:00
Update go.sum, main.go, and 10 more files...
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
"mizuserver/pkg/models"
|
||||
"mizuserver/pkg/utils"
|
||||
)
|
||||
@@ -12,9 +13,7 @@ const (
|
||||
DBPath = "./entries.db"
|
||||
)
|
||||
|
||||
var (
|
||||
DB = initDataBase(DBPath)
|
||||
)
|
||||
var DB *gorm.DB
|
||||
|
||||
const (
|
||||
OrderDesc = "desc"
|
||||
@@ -34,13 +33,19 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
DB = initDataBase(DBPath)
|
||||
go StartEnforcingDatabaseSize()
|
||||
}
|
||||
|
||||
func GetEntriesTable() *gorm.DB {
|
||||
return DB.Table("mizu_entries")
|
||||
}
|
||||
|
||||
func initDataBase(databasePath string) *gorm.DB {
|
||||
go StartEnforcingDatabaseSize( 10 * 1000 * 1000)
|
||||
temp, _ := gorm.Open(sqlite.Open(databasePath), &gorm.Config{})
|
||||
temp, _ := gorm.Open(sqlite.Open(databasePath), &gorm.Config{
|
||||
Logger: logger.Default.LogMode(logger.Silent),
|
||||
})
|
||||
_ = temp.AutoMigrate(&models.MizuEntry{}) // this will ensure table is created
|
||||
return temp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user