Partly my elbow grease, partly Sonnet 4 via Zed, partly Sonnet 4 via
Jetbrains AI Chat; see individual 🤖 commits for prompts.
This gets us partway to #28189. Tested/confirmed with #31481. Internal
tool, hence no changes file.
# Checklist for submitter
- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
## Testing
- [x] QA'd all new/changed functionality manually