kiwicopple@pg_idkit
pg_idkit
Useful ID generators and utilities. A pure PL/pgSQL port of the popular Rust version.
The goal is to have no additional extension requirements (eg: no pgcrypto) to maintain portability.
- Source: https://github.com/kiwicopple/pg-extensions/tree/main/pg_idkit
- Docs: https://github.com/kiwicopple/pg-extensions/tree/main/pg_idkit
- DbDev: https://database.dev/kiwicopple/pg_idkit
Usage
Function signatures follows a similar pattern to the built-in
gen_random_uuid_v6()
- generate a random UUID v6gen_random_uuid_v7()
- generate a random UUID v7gen_random_ksuid_second()
- generate a random KSUID with second-level precisiongen_random_ksuid_microsecond()
- generate a random KSUID with microsecond-level precisiontimestamp_from_uuid_v7(uuidv7, timezone?)
- extract a timestamp from a UUIDv7. Optionally provide timezone (like 'America/New_York')
Installation
dbdev install kiwicopple-pg_idkit --connection <CONNECTION_STRING>
or
select * from dbdev('kiwicopple-pg_idkit')
then:
create extension pg_idkit;
or to install in a separate schema (recommended):
create extension pg_idkit with schema extensions;
Credits
fabiolimace
. Most of the work of this repo can be attributed to Fabio's gists on GitHub.
Install
- Install the
dbdev
package manager - Install the package:
select dbdev.install('kiwicopple@pg_idkit');
create extension "kiwicopple@pg_idkit"
version '0.0.4';
Downloads
- 4474 all time downloads
- 95 downloads in the last 30 days
- 735 downloads in the last 90 days
- 2156 downloads in the last 180 days