4 ms·
Fully agree. For example, it's very handy that GitHub issues are auto incrementing integers starting at 1, so that I can type "Fixes #123" in a commit message i
by kevsim 7y ago
Fully agree. For example, it's very handy that GitHub issues are auto incrementing integers starting at 1, so that I can type "Fixes #123" in a commit message instead of "Fixes #<some-uuid-or-something>".
Of course, that short numeric ID doesn't necessarily need to be part of the DB's primary key.
- slig 7y agoIs there any best practice on implementing an ID field that starts at 1 for each repository (in GH's example)?
- dexterdog 7y agoIf you're using a UUID you can just use whichever huge integer your UUID represents and then increment from there so the records are all sequential 128bit numbers.
- kevsim 7y agoI guess it would be pretty easy in postgres to create a sequence per repository and have the field use the next value in the sequence (i.e. like it normally does for auto incrementing IDs but where you'd specify the sequence to use at insert time).
- slig 7y agoThanks, I'll have a look!
- nly 7y agoHow would one go about implementing user scoped autoincrement fields efficiently in modern databases anyway? Triggers?