kiwicopple-pg_idkit

v0.0.4Created 6 months agoBy kiwicopple

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.

Usage

Function signatures follows a similar pattern to the built-in

  • gen_random_uuid_v6() - generate a random UUID v6
  • gen_random_uuid_v7() - generate a random UUID v7
  • gen_random_ksuid_second() - generate a random KSUID with second-level precision
  • gen_random_ksuid_microsecond() - generate a random KSUID with microsecond-level precision
  • timestamp_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

  1. Install the dbdev package manager
  2. Install the package:
select dbdev.install('kiwicopple-pg_idkit');
create extension "kiwicopple-pg_idkit"
    version '0.0.4';

Downloads

  • 2667 all time downloads
  • 511 downloads in the last 30 days
  • 2349 downloads in the last 90 days
  • 2667 downloads in the last 180 days