MCPcopy Create free account
hub / github.com/Mirouterui/mirouter-ui / CheckDatabase

Function CheckDatabase

modules/database/base.go:69–85  ·  view source on GitHub ↗

CheckDatabase checks the SQLite database file at the given path. Parameters: - databasePath: a string variable that holds the path to the SQLite database file. Returns: None.

(databasePath string)

Source from the content-addressed store, hash-verified

67//
68// Returns: None.
69func CheckDatabase(databasePath string) {
70 // databasePath is a variable that holds the path to the SQLite database file
71 db, err := gorm.Open(sqlite.Open(databasePath), &gorm.Config{})
72 checkErr(err)
73
74 // Check if the history table exists, if not, create it
75 err = db.AutoMigrate(&RouterHistory{})
76 checkErr(err)
77 err = db.AutoMigrate(&DevicesHistory{})
78 checkErr(err)
79 // Perform CRUD operations on the history table using db.Create, db.First, db.Update, db.Delete methods
80 defer func() {
81 sqlDB, err := db.DB()
82 checkErr(err)
83 sqlDB.Close()
84 }()
85}
86
87// Savetodb saves device statistics to the database.
88//

Callers 1

mainFunction · 0.92

Calls 1

checkErrFunction · 0.70

Tested by

no test coverage detected