enabled sqlite3 auto_vacuum

This commit is contained in:
Steve White 2024-10-17 10:07:12 -05:00
parent 0f2b213406
commit ccb53c85c6
1 changed files with 3 additions and 0 deletions

3
db.go
View File

@ -36,6 +36,9 @@ func ConnectDB(dbPath string) (*gorm.DB, error) {
return nil, fmt.Errorf("failed to connect to database: %v", err) return nil, fmt.Errorf("failed to connect to database: %v", err)
} }
// set auto_vacuum mode to ON
// this automagically removes old rows from the database when idle
db.Exec("PRAGMA auto_vacuum = ON;")
// AutoMigrate will create the tables if they don't exist // AutoMigrate will create the tables if they don't exist
db.AutoMigrate(&Box{}, &Item{}, &User{}) db.AutoMigrate(&Box{}, &Item{}, &User{})