Marcin Piczkowski
Posted on August 20, 2020
I'm thinking of usage of text IDs in SQL database, similar to how Stripe generates them, e.g.: ch_19iRv22eZvKYlo2CAxkjuHxZ
.
I found this StackOverflow very helpful.
I could use the function to generate such IDs with some entropy provided by pgcrypto
extension function gen_random_bytes
, but still, I'm hesitant.
Especially, after reading this comment:
No, it absolutely is not safe to use in any way shape or form which is why I'm for closing this question. If you want something that's safe to use, use UUID. If you want to play around with something likely to burn you severely and leave you crying. A solution which requires you create your own function that is worse in every way than the stock feature set to do this, then have it at. =)
I would not like to reach a point later on production when the IDs start to duplicate.
Therefore, I'm more biased to use UUIDs, which on the other hand are not very user-friendly, e.g. when they are used in URLs, reports, etc. I personally like the way Stripe does it.
What's your experience? Did anyone do sth similar to Stripe? Did you face any problems?
Posted on August 20, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.