diff --git a/engine/storage_sql.go b/engine/storage_sql.go index e7f5f5cf5..690b19d79 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -216,11 +216,15 @@ func (self *SQLStorage) SetTPDestination(tpid string, dest *Destination) error { tx := self.db.Begin() tx.Where("tpid = ?", tpid).Where("id = ?", dest.Id).Delete(TpDestination{}) for _, prefix := range dest.Prefixes { - tx.Save(TpDestination{ + db := tx.Save(TpDestination{ Tpid: tpid, Id: dest.Id, Prefix: prefix, }) + if db.Error != nil { + tx.Rollback() + return db.Error + } } tx.Commit() return nil