db: Handle repo upserts which rename
Created by: keegancsmith
If we have the same external service but different name it indicates a rename has occurred. So we update the upsert to do an update if we match on name or external repo. We also simplify the insert to only happen if the update did not.
Part of #2025 (closed) Fixes #2690 (closed)