database: Faster external service deletion
Created by: ryanslade
Instead of scanning the entire repo table looking for orphaned repos after an external service has been deleted, we instead only scan repos we know may have been affected.
We had to use a temporary table since if the deletion was done in a CTE it is not visible in subsequent statements.
We also remove the trigger after external service is deleted as we take care of it in code.
Closes: https://github.com/sourcegraph/sourcegraph/issues/19513