Feat: auto delete alias when unused
Some checks failed
Go test / run-go-vet (push) Successful in 5s
Go test / check-swagger-up-to-date (push) Successful in 10s
Go test / run-go-test (push) Failing after 11s
Go test / release-image (push) Has been skipped
Go test / cleanup-go-test (push) Successful in 3s

This commit is contained in:
2025-12-13 01:49:04 +08:00
parent 6b5b7d257d
commit 875db5a8dd
4 changed files with 31 additions and 6 deletions

View File

@@ -191,6 +191,7 @@ func (self *BunDatabase) UpdateAliases(
if err != nil {
return err
}
_, err = tx.NewDelete().
Model((*models.AliasImage)(nil)).
Where("image_id = ?", imageId).
@@ -214,6 +215,14 @@ func (self *BunDatabase) UpdateAliases(
return err
}
_, err = tx.NewDelete().
Model((*models.Alias)(nil)).
Where("NOT EXISTS (?)", tx.NewSelect().
Model((*models.AliasImage)(nil)).
Where("alias.id = alias_image.alias_id").
Limit(1)).
Exec(ctx)
return nil
})
}