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.
()
| 490 | // periodic maintenance goroutine to use PRAGMA incremental_vacuum to |
| 491 | // efficiently reclaim free pages without rebuilding the entire database. |
| 492 | func (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 | |
| 510 | func (s *sqlDatabase) enableIncrementalVacuum(conn *gorm.DB, dbName string) error { |
| 511 | var autoVacuum int |
no test coverage detected