Skip to content

repo-updater: Soft delete rows in the repo table

Created by: keegancsmith

Currently we hard delete repositories in the repo table. This is to prevent conflicts on the name, since making the diff algorithm aware of "soft deleted" repositories and correctly updating names is complicated. However, we want to introduce an API which associates permissions with repository IDs. Given the repo-updater does hard deletes, the Sourcegraph ID is not stable across a repository being synced or not. A repository may be accidentally removed by an administrator, or a bug in our software would accidentally remove a repository. Requiring a resync on permissions is hard to notice and an extra burden on administrators.

Proposal:

There are a few ways to implement this and prevent the name conflicts we are concerned about. They all involve introducing a deleted_at column, which when non-null indicates the repository is no longer visible to anyone. I believe the simplest way to prevent name conflicts on deleted repositories is to rename them to DELETED-$RANDOMSTRING-$NAME.

I am unsure of other parts of code that may require updating. In particular we may have postgresql triggers for repository removal that would need updating.

Part of https://github.com/sourcegraph/sourcegraph/issues/6086