VADOSWARE/pg_idkit

Postgres extension for generating UUIDs

Dockerfile

424

274 commits

updated Sep 10, 2026

See the code

README

🐘 πŸͺͺ `pg_idkit`

postgres=# CREATE EXTENSION pg_idkit;
CREATE EXTENSION

postgres=# SELECT idkit_uuidv7_generate();
        idkit_uuidv7_generate
--------------------------------------
 018c106f-9304-79bb-b5be-4483b92b036c

Description

pg_idkit is a Postgres extension for generating many popular types of identifiers:

MethodologyFunctionCrateDescription
UUID v6idkit_uuidv6_generate()uuidv6UUID v6 (RFC 4122)
idkit_uuidv6_generate_uuid()
idkit_uuidv6_extract_timestamptz(TEXT)
UUID v7idkit_uuidv7_generate()uuid7UUID v7 (RFC 4122)
idkit_uuidv7_generate_uuid()
idkit_uuidv7_extract_timestamptz(TEXT)
nanoididkit_nanoid_generate()nanoidNanoID, developed by Andrey Sitnik
idkit_nanoid_custom_generate_text()nanoidNanoID with a custom length and alphabet
ksuididkit_ksuid_generate()svix-ksuidCreated by Segment
idkit_ksuid_extract_timestamptz(TEXT)
idkit_ksuidms_generate()svix-ksuidSame as ksuid but with millisecond precision
idkit_ksuidms_extract_timestamptz(TEXT)
ulididkit_ulid_generate()ulidUnique, lexicographically sortable identifiers
idkit_ulid_extract_timestamptz(TEXT)
Timeflakeidkit_timeflake_generate()timeflake-rsTwitter's Snowflake + Instagram's ID + Firebase's PushID
idkit_timeflake_extract_timestamptz(TEXT)
PushIDidkit_pushid_generate()pushidGoogle Firebase's PushID
xididkit_xid_generate()xidXID
idkit_xid_extract_timestamptz(TEXT)
cuid (deprecated)idkit_cuid_generate()cuidCUID
idkit_cuid_extract_timestamptz(TEXT)
cuid2idkit_cuid2_generate()cuid2CUID2
idkit_cuid2_generate_with_len(length)CUID2 with custom length
[typeid][typeid]idkit_typeid_generate(TEXT)type-safe-idTYPEID with provided prefix and UUIDv7 now()
idkit_typeid_generate_text(TEXT)TYPEID with provided prefix and UUIDv7 now()
idkit_typeid_from_uuid_v7(TEXT, TEXT)TYPEID from a given UUID v7
idkit_typeid_extract_timestamptz(TEXT)Extract a timestamp from a given typeid

This Postgres extension is made possible thanks to [pgrx][pgrx].

Quickstart

You can try out pg_idkit incredibly quickly by using docker, and a previously released package of pg_idkit:

docker run \
    --rm \
    -e POSTGRES_PASSWORD=replace_this \
    -p 5432 \
    --name pg_idkit \
    ghcr.io/vadosware/pg_idkit:0.4.0-pg18.0-alpine3.22.2-amd64

[!WARNING] Currently only amd64 (x86_64) images are present/supported (See pg_idkit packages).

Work to support more platforms is described in issue #30

Once the postgres server is running, open another shell and connect to the dockerized Postgres instance running on port 5432:

➜ docker exec -it pg_idkit psql -U postgres
psql (18.0)
Type "help" for help.

postgres=# CREATE EXTENSION pg_idkit;
CREATE EXTENSION

postgres=# SELECT idkit_uuidv7_generate();
        idkit_uuidv7_generate
--------------------------------------
 018c106f-9304-79bb-b5be-4483b92b036c
(1 row)

Installing pg_idkit

πŸ“ƒ From Source

Source install

To build pg_idkit from source, clone this repository and run the following:

cargo install cargo-get cargo-pgrx just
just package

After running these commands you should see the following directory structure in target/release/pg_idkit-pg18:

target/release/pg_idkit-pg18
β”œβ”€β”€ home
β”‚Β Β  └── <user>
β”‚Β Β      └── .pgrx
β”‚Β Β          └── 18.0
β”‚Β Β              └── pgrx-install
β”‚Β Β                  β”œβ”€β”€ lib
β”‚Β Β                  β”‚Β Β  └── postgresql
β”‚Β Β                  β”‚Β Β      └── pg_idkit.so
β”‚Β Β                  └── share
β”‚Β Β                      └── postgresql
β”‚Β Β                          └── extension
β”‚Β Β                              β”œβ”€β”€ pg_idkit--0.4.0.sql
β”‚Β Β                              └── pg_idkit.control
└── usr
    β”œβ”€β”€ lib
    β”‚Β Β  └── postgresql
    β”‚Β Β      └── pg_idkit.so
    └── share
        └── postgresql
            └── extension
                └── pg_idkit.control

24 directories, 8 files

As the installation of the extension into a specific version of postgres uses your local installation of pgrx-managed Postgres by default (normally at $HOME/.pgrx), cargo pgrx package reproduces the directory structure in target/release. You can safely ignore the shorter usr/lib/user/share tree.

In the example above, the files you need for a Postgres extension are:

  • target/release/home/<user>/.pgrx/18.0/pgrx-install/lib/postgresql/pg_idkit.so
  • target/release/home/<user>/.pgrx/18.0/pgrx-install/share/postgresql/extension/pg_idkit--0.4.0.sql
  • target/release/home/<user>/.pgrx/18.0/pgrx-install/share/postgresql/extension/pg_idkit.control

Install these files in the relevant folders for your Postgres installation -- note that exactly where these files should go can can differ across linux distributions and containerized environments.

πŸ’½ From Binary

Binary install

If running a custom version of locally/globally manually installed Postgres, you may download (and verify the checksum of) a shared library version from the releases, and add it as one of your shared_preload_libraries in postgresql.conf.

Assuming you have downloaded the pg_idkit-vX.X.X.so file to /etc/postgresql/extensions, you might change the file like this:

postgresql.conf

shared_preload_libraries = '/etc/postgresql/extensions/pg_idkit-vX.X.X.so'

Once your postgres instance is started up, you should be able to CREATE EXTENSION:

postgres=# CREATE EXTENSION pg_idkit;
CREATE EXTENSION
postgres=# SELECT idkit_uuidv7_generate();
        idkit_uuidv7_generate
--------------------------------------
 018c106f-9304-79bb-b5be-4483b92b036c
🐳 Dockerfile

Dockerfile

To use pg_idkit easily from a containerized environment, you can use the pg_idkit image, built from postgres:

docker run \
    --rm \
    -e POSTGRES_PASSWORD=replace_this \
    -p 5432 \
    --name pg_idkit \
    ghcr.io/vadosware/pg_idkit:0.4.0-pg18.0-alpine3.22.2-amd64

From another terminal, you can exec into the pg_idkit container and enable pg_idkit:

➜ docker exec -it pg_idkit psql -U postgres
psql (18.0)
Type "help" for help.

postgres=# CREATE EXTENSION pg_idkit;
CREATE EXTENSION
postgres=# SELECT idkit_uuidv7_generate();
        idkit_uuidv7_generate
--------------------------------------
 018c106f-9304-79bb-b5be-4483b92b036c
(1 row)

[!WARNING] Currently only amd64 (x86_64) images are present/supported (See pg_idkit packages).

Work to support more platforms is described in issue #30

πŸ“¦ Debian (RPM)

RPM install

RPMs are produced upon every official release of pg_idkit.

Grab a released version of the RPM (or build one yourself by running just build-rpm after setting up local development).

For example, with an RPM named pg_idkit-0.4.0-pg18.x86_64.rpm, you should be able to run:

dnf install pg_idkit-0.4.0-pg18.x86_64.rpm

Prior Art

There are some other projects in the Postgres ecosystem that implement alternative UUID generation mechanisms.

Here are some you may or may not have heard of:

Setting up for local development

Interested in contributing on the project? Set up your local development environment w/ docs/local-development.md.

Contributing

Contributions are welcome!

If you find a bug or an impovement that should be included in pg_idkit, create an issue.

If you'd like to contribute code, get started by:

  1. Reading the local development guide
  2. Creating an issue (if necessary) to explain the new feature/bugfix/etc
  3. Forking this repository
  4. Creating a feature/bugfix/etc branch (we expect [conventional commits][conventional-commits], i.e. feat: new awesome feature)
  5. Opening a Pull Request to this repository

FAQ/Common Issues

Error: pgXX is not managed by pgrx

If you find this, you're likely using a version of cargo-pgrx that is too old.

cargo install --locked cargo-pgrx
postgresql

Contributors

t3hmrman

205 commits

dependabot[bot]

61 commits

Vonng

2 commits

Morgul

1 commits

VADOSWARE/pg_idkit

Postgres extension for generating UUIDs

Dockerfile

424

274 commits

updated Sep 10, 2026

See the code

README

🐘 πŸͺͺ `pg_idkit`

postgres=# CREATE EXTENSION pg_idkit;
CREATE EXTENSION

postgres=# SELECT idkit_uuidv7_generate();
        idkit_uuidv7_generate
--------------------------------------
 018c106f-9304-79bb-b5be-4483b92b036c

Description

pg_idkit is a Postgres extension for generating many popular types of identifiers:

MethodologyFunctionCrateDescription
UUID v6idkit_uuidv6_generate()uuidv6UUID v6 (RFC 4122)
idkit_uuidv6_generate_uuid()
idkit_uuidv6_extract_timestamptz(TEXT)
UUID v7idkit_uuidv7_generate()uuid7UUID v7 (RFC 4122)
idkit_uuidv7_generate_uuid()
idkit_uuidv7_extract_timestamptz(TEXT)
nanoididkit_nanoid_generate()nanoidNanoID, developed by Andrey Sitnik
idkit_nanoid_custom_generate_text()nanoidNanoID with a custom length and alphabet
ksuididkit_ksuid_generate()svix-ksuidCreated by Segment
idkit_ksuid_extract_timestamptz(TEXT)
idkit_ksuidms_generate()svix-ksuidSame as ksuid but with millisecond precision
idkit_ksuidms_extract_timestamptz(TEXT)
ulididkit_ulid_generate()ulidUnique, lexicographically sortable identifiers
idkit_ulid_extract_timestamptz(TEXT)
Timeflakeidkit_timeflake_generate()timeflake-rsTwitter's Snowflake + Instagram's ID + Firebase's PushID
idkit_timeflake_extract_timestamptz(TEXT)
PushIDidkit_pushid_generate()pushidGoogle Firebase's PushID
xididkit_xid_generate()xidXID
idkit_xid_extract_timestamptz(TEXT)
cuid (deprecated)idkit_cuid_generate()cuidCUID
idkit_cuid_extract_timestamptz(TEXT)
cuid2idkit_cuid2_generate()cuid2CUID2
idkit_cuid2_generate_with_len(length)CUID2 with custom length
[typeid][typeid]idkit_typeid_generate(TEXT)type-safe-idTYPEID with provided prefix and UUIDv7 now()
idkit_typeid_generate_text(TEXT)TYPEID with provided prefix and UUIDv7 now()
idkit_typeid_from_uuid_v7(TEXT, TEXT)TYPEID from a given UUID v7
idkit_typeid_extract_timestamptz(TEXT)Extract a timestamp from a given typeid

This Postgres extension is made possible thanks to [pgrx][pgrx].

Quickstart

You can try out pg_idkit incredibly quickly by using docker, and a previously released package of pg_idkit:

docker run \
    --rm \
    -e POSTGRES_PASSWORD=replace_this \
    -p 5432 \
    --name pg_idkit \
    ghcr.io/vadosware/pg_idkit:0.4.0-pg18.0-alpine3.22.2-amd64

[!WARNING] Currently only amd64 (x86_64) images are present/supported (See pg_idkit packages).

Work to support more platforms is described in issue #30

Once the postgres server is running, open another shell and connect to the dockerized Postgres instance running on port 5432:

➜ docker exec -it pg_idkit psql -U postgres
psql (18.0)
Type "help" for help.

postgres=# CREATE EXTENSION pg_idkit;
CREATE EXTENSION

postgres=# SELECT idkit_uuidv7_generate();
        idkit_uuidv7_generate
--------------------------------------
 018c106f-9304-79bb-b5be-4483b92b036c
(1 row)

Installing pg_idkit

πŸ“ƒ From Source

Source install

To build pg_idkit from source, clone this repository and run the following:

cargo install cargo-get cargo-pgrx just
just package

After running these commands you should see the following directory structure in target/release/pg_idkit-pg18:

target/release/pg_idkit-pg18
β”œβ”€β”€ home
β”‚Β Β  └── <user>
β”‚Β Β      └── .pgrx
β”‚Β Β          └── 18.0
β”‚Β Β              └── pgrx-install
β”‚Β Β                  β”œβ”€β”€ lib
β”‚Β Β                  β”‚Β Β  └── postgresql
β”‚Β Β                  β”‚Β Β      └── pg_idkit.so
β”‚Β Β                  └── share
β”‚Β Β                      └── postgresql
β”‚Β Β                          └── extension
β”‚Β Β                              β”œβ”€β”€ pg_idkit--0.4.0.sql
β”‚Β Β                              └── pg_idkit.control
└── usr
    β”œβ”€β”€ lib
    β”‚Β Β  └── postgresql
    β”‚Β Β      └── pg_idkit.so
    └── share
        └── postgresql
            └── extension
                └── pg_idkit.control

24 directories, 8 files

As the installation of the extension into a specific version of postgres uses your local installation of pgrx-managed Postgres by default (normally at $HOME/.pgrx), cargo pgrx package reproduces the directory structure in target/release. You can safely ignore the shorter usr/lib/user/share tree.

In the example above, the files you need for a Postgres extension are:

  • target/release/home/<user>/.pgrx/18.0/pgrx-install/lib/postgresql/pg_idkit.so
  • target/release/home/<user>/.pgrx/18.0/pgrx-install/share/postgresql/extension/pg_idkit--0.4.0.sql
  • target/release/home/<user>/.pgrx/18.0/pgrx-install/share/postgresql/extension/pg_idkit.control

Install these files in the relevant folders for your Postgres installation -- note that exactly where these files should go can can differ across linux distributions and containerized environments.

πŸ’½ From Binary

Binary install

If running a custom version of locally/globally manually installed Postgres, you may download (and verify the checksum of) a shared library version from the releases, and add it as one of your shared_preload_libraries in postgresql.conf.

Assuming you have downloaded the pg_idkit-vX.X.X.so file to /etc/postgresql/extensions, you might change the file like this:

postgresql.conf

shared_preload_libraries = '/etc/postgresql/extensions/pg_idkit-vX.X.X.so'

Once your postgres instance is started up, you should be able to CREATE EXTENSION:

postgres=# CREATE EXTENSION pg_idkit;
CREATE EXTENSION
postgres=# SELECT idkit_uuidv7_generate();
        idkit_uuidv7_generate
--------------------------------------
 018c106f-9304-79bb-b5be-4483b92b036c
🐳 Dockerfile

Dockerfile

To use pg_idkit easily from a containerized environment, you can use the pg_idkit image, built from postgres:

docker run \
    --rm \
    -e POSTGRES_PASSWORD=replace_this \
    -p 5432 \
    --name pg_idkit \
    ghcr.io/vadosware/pg_idkit:0.4.0-pg18.0-alpine3.22.2-amd64

From another terminal, you can exec into the pg_idkit container and enable pg_idkit:

➜ docker exec -it pg_idkit psql -U postgres
psql (18.0)
Type "help" for help.

postgres=# CREATE EXTENSION pg_idkit;
CREATE EXTENSION
postgres=# SELECT idkit_uuidv7_generate();
        idkit_uuidv7_generate
--------------------------------------
 018c106f-9304-79bb-b5be-4483b92b036c
(1 row)

[!WARNING] Currently only amd64 (x86_64) images are present/supported (See pg_idkit packages).

Work to support more platforms is described in issue #30

πŸ“¦ Debian (RPM)

RPM install

RPMs are produced upon every official release of pg_idkit.

Grab a released version of the RPM (or build one yourself by running just build-rpm after setting up local development).

For example, with an RPM named pg_idkit-0.4.0-pg18.x86_64.rpm, you should be able to run:

dnf install pg_idkit-0.4.0-pg18.x86_64.rpm

Prior Art

There are some other projects in the Postgres ecosystem that implement alternative UUID generation mechanisms.

Here are some you may or may not have heard of:

Setting up for local development

Interested in contributing on the project? Set up your local development environment w/ docs/local-development.md.

Contributing

Contributions are welcome!

If you find a bug or an impovement that should be included in pg_idkit, create an issue.

If you'd like to contribute code, get started by:

  1. Reading the local development guide
  2. Creating an issue (if necessary) to explain the new feature/bugfix/etc
  3. Forking this repository
  4. Creating a feature/bugfix/etc branch (we expect [conventional commits][conventional-commits], i.e. feat: new awesome feature)
  5. Opening a Pull Request to this repository

FAQ/Common Issues

Error: pgXX is not managed by pgrx

If you find this, you're likely using a version of cargo-pgrx that is too old.

cargo install --locked cargo-pgrx
postgresql

Contributors

t3hmrman

205 commits

dependabot[bot]

61 commits

Vonng

2 commits

Morgul

1 commits

Languages

Dockerfile

43.6%

Rust

42.9%

Just

13.5%