reduce unnecessary sqlite indexes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-06 08:53:36 +11:00
parent 32ced35130
commit 5dcc11e5e0
3 changed files with 103 additions and 2 deletions

10
main.go
View File

@@ -39,6 +39,7 @@ const fallbackEncryptionKey = "5L1l3B5KvwOCzUHMAlCgsgUTRAYMfSpa"
func main() {
settingsPath := flag.String("settings", "/etc/dtms/vctp.yml", "Path to settings YAML")
runInventory := flag.Bool("run-inventory", false, "Run a single inventory snapshot across all configured vCenters and exit")
dbCleanup := flag.Bool("db-cleanup", false, "Run a one-time cleanup to drop low-value hourly snapshot indexes and exit")
flag.Parse()
bootstrapLogger := log.New(log.LevelInfo, log.OutputText)
@@ -87,6 +88,15 @@ func main() {
logger.Error("failed to migrate database", "error", err)
os.Exit(1)
}
if *dbCleanup {
dropped, err := db.CleanupHourlySnapshotIndexes(ctx, database.DB())
if err != nil {
logger.Error("failed to cleanup hourly snapshot indexes", "error", err)
os.Exit(1)
}
logger.Info("completed hourly snapshot index cleanup", "indexes_dropped", dropped)
return
}
// Determine bind IP
bindIP := strings.TrimSpace(s.Values.Settings.BindIP)