From 671f8da872b0decaf217bd4e4d0119d974b1160d Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Tue, 20 Feb 2024 10:19:05 +0100 Subject: [PATCH] stores: add migration to performMigrations --- stores/metadata.go | 6 +++--- stores/migrations.go | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/stores/metadata.go b/stores/metadata.go index a9636bf75..13f274477 100644 --- a/stores/metadata.go +++ b/stores/metadata.go @@ -2689,9 +2689,9 @@ func pruneSlabs(tx *gorm.DB) error { // delete slabs without any associated slices or buffers return tx.Exec(` DELETE -FROM slabs sla -WHERE NOT EXISTS (SELECT 1 FROM slices sli WHERE sli.db_slab_id = sla.id) -AND sla.db_buffered_slab_id IS NULL +FROM slabs +WHERE NOT EXISTS (SELECT 1 FROM slices WHERE slices.db_slab_id = slabs.id) +AND slabs.db_buffered_slab_id IS NULL `).Error } diff --git a/stores/migrations.go b/stores/migrations.go index bf3916ca4..d89be7ab5 100644 --- a/stores/migrations.go +++ b/stores/migrations.go @@ -44,6 +44,12 @@ func performMigrations(db *gorm.DB, logger *zap.SugaredLogger) error { return performMigration(tx, dbIdentifier, "00003_idx_objects_size", logger) }, }, + { + ID: "00004_prune_slabs_cascade", + Migrate: func(tx *gorm.DB) error { + return performMigration(tx, dbIdentifier, "00004_prune_slabs_cascade", logger) + }, + }, } // Create migrator.