You Should Add Debug Views to Your DB

https://news.ycombinator.com/rss Hits: 6
Summary

This one will be quick. Imagine this, you get a report from your bug tracker: Sophie got an error when viewing the diff after her most recent push to her contribution to the @unison/cloud project on Unison Share (BTW, contributions are like pull requests, but for Unison code) Okay, this is great, we have something to start with, let's go look up that contribution and see if any of the data there is suspicious. Uhhh, okay, I know the error is related to one of Sophie's contributions, but how do I actually find it? I know Sophie's username from the bug report, that helps, but I don't know which project she was working on, or what the contribution ID is, which branches are involved, etc. Okay no problem, our data is relational, so I can dive in and figure it out with a query: > SELECT contribution.* FROM contributions AS contribution JOIN projects AS project ON contribution.project_id = project.id JOIN users AS unison_user ON project.owner = unison_user.id JOIN users AS contribution_author ON contribution.author_id = contribution_author.id JOIN branches AS source_branch ON contribution.source_branch = source_branch.id WHERE contribution_author.username = 'sophie' AND project.name = 'cloud' AND unison_user.username = 'unison' ORDER BY source_branch.updated_at DESC -[ RECORD 1 ]--------+---------------------------------------------------- id | C-4567 project_id | P-9999 contribution_number | 21 title | Fix bug description | Prevent the app from deleting the User's hard drive status | open source_branch | B-1111 target_branch | B-2222 created_at | 2025-05-28 13:06:09.532103+00 updated_at | 2025-05-28 13:54:23.954913+00 author_id | U-1234 It's not the worst query I've ever had to write out, but if you're doing this a couple times a day on a couple different tables, writing out the joins gets pretty old real fast. Especially so if you're writing it in a CLI interface where's it's a royal pain to edit the middle of a query. Even after we get the data we get a very ID heavy v...

First seen: 2025-08-21 15:12

Last seen: 2025-08-21 21:30