db: delete pre-auth key on its own savepoint

This commit is contained in:
Michael Lopez
2026-09-23 15:24:22 +02:00
committed by GitHub
parent 4cad0b564e
commit fdcdebb392
+3 -2
View File
@@ -341,8 +341,9 @@ func DestroyPreAuthKey(tx *gorm.DB, id uint64) error {
return fmt.Errorf("clearing auth_key_id on nodes: %w", err) return fmt.Errorf("clearing auth_key_id on nodes: %w", err)
} }
// Then delete the pre-auth key // Then delete the pre-auth key, on the same savepoint as the
res := tx.Unscoped().Delete(&types.PreAuthKey{}, id) // node update so both roll back together.
res := db.Unscoped().Delete(&types.PreAuthKey{}, id)
if res.Error != nil { if res.Error != nil {
return res.Error return res.Error
} }