Skip to content

Commit

Permalink
stores: add migration to performMigrations
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed Feb 20, 2024
1 parent 1f00422 commit 671f8da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions stores/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 6 additions & 0 deletions stores/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 671f8da

Please sign in to comment.