db: manually execute deletion of orphaned repos
Created by: asdine
Orphaned repos cleanup is no longer triggered when we delete rows from external_service_repos
. Instead, we manually run it when an external service is being deleted or after an external service sync.
Previously, we had a cyclical trigger:
- External service is soft deleted
- All associated rows in external_service_repo are deleted
- (1) Trigger: Deletion of orphaned repos.
- (2) Trigger: Deletion of associated rows in external_service_repos again
- (1) Trigger: Deletion of orphaned repos again
When deleting a repo, we don't need to run (1) which is really slow because it needs to scan the whole repo table.