MCPcopy Create free account
hub / github.com/cloudbase/garm / migrateAutoVacuum

Method migrateAutoVacuum

database/sql/sql.go:492–508  ·  view source on GitHub ↗

migrateAutoVacuum converts SQLite databases from auto_vacuum=NONE to auto_vacuum=INCREMENTAL. This is a one-time migration that allows the periodic maintenance goroutine to use PRAGMA incremental_vacuum to efficiently reclaim free pages without rebuilding the entire database.

()

Source from the content-addressed store, hash-verified

490// periodic maintenance goroutine to use PRAGMA incremental_vacuum to
491// efficiently reclaim free pages without rebuilding the entire database.
492func (s *sqlDatabase) migrateAutoVacuum() error {
493 if s.cfg.DbBackend != config.SQLiteBackend {
494 return nil
495 }
496
497 if err := s.enableIncrementalVacuum(s.conn, "main"); err != nil {
498 return err
499 }
500
501 if s.objectsConn != nil {
502 if err := s.enableIncrementalVacuum(s.objectsConn, "objects"); err != nil {
503 return err
504 }
505 }
506
507 return nil
508}
509
510func (s *sqlDatabase) enableIncrementalVacuum(conn *gorm.DB, dbName string) error {
511 var autoVacuum int

Callers 1

migrateDBMethod · 0.95

Calls 1

Tested by

no test coverage detected