Can we use ULIDs without a dedicated cluster?

We are looking for some solution between a Postgres serial and a long UUID. So ULIDs are a natural choice. I would use something like https://github.com/geckoboard/pgulid or https://github.com/pksunkara/pgx_ulid. But without a dedicated cluster we cannot create types/functions. So is there another way to use ULID-like IDs? I've seen that select ('rec_'::text || (xata_private.xid())::text) produces a similar result. Can we use this for the foreseeable future for our own ID fields?
GitHub
GitHub - geckoboard/pgulid: Universally Unique Lexicographically So...
Universally Unique Lexicographically Sortable Identifier (ULID) for PostgreSQL - geckoboard/pgulid
3 Replies
kostas
kostas6mo ago
Hi, the uuid-ossp extension is available if that could be of use to you: https://www.postgresql.org/docs/current/uuid-ossp.html Indeed, functions and other extensions are only available with Dedicated Clusters. The xata_id is generated as a unique string (at the table level at least, but it might also be at the branch level. I'll find out if you're interested) and limited to 255 chars consisting of numbers and letters only.
PostgreSQL Documentation
F.49. uuid-ossp — a UUID generator
F.49. uuid-ossp — a UUID generator # F.49.1. uuid-ossp Functions F.49.2. Building uuid-ossp F.49.3. Author The uuid-ossp module provides functions to …
kostas
kostas6mo ago
Update: xata_id is unique at the branch level You can use that default setup in your own id columns
Michael Schaufelberger
OK, thanks! In that case, we will use what xata_id uses. For custom ULIDs we would need to create a function to generate them. (We want to not have long UUIDs but shorter ULIDs)
Want results from more Discord servers?
Add your server