3 points:
- I would count SQL as code
- This appears to have affected default badges. I certainly hope that the SQL for those badges is in the code repository.
- If the trigger SQL was faulty, then just deleting the bad badges would not actually fix the issue. The underlying SQL would need to be fixed.