{"id":13880538,"url":"https://github.com/VADOSWARE/pg_idkit","last_synced_at":"2025-07-16T17:30:39.401Z","repository":{"id":59387524,"uuid":"520058706","full_name":"VADOSWARE/pg_idkit","owner":"VADOSWARE","description":"Postgres extension for generating UUIDs","archived":false,"fork":false,"pushed_at":"2025-06-25T19:58:01.000Z","size":375,"stargazers_count":401,"open_issues_count":3,"forks_count":11,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-25T20:35:43.396Z","etag":null,"topics":["postgresql"],"latest_commit_sha":null,"homepage":"https://vadosware.io/post/introducing-pg-idkit/","language":"Dockerfile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VADOSWARE.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-08-01T10:09:50.000Z","updated_at":"2025-06-25T19:58:03.000Z","dependencies_parsed_at":"2023-02-17T12:01:03.353Z","dependency_job_id":"3570422d-6579-4831-8c15-fe70c91144e1","html_url":"https://github.com/VADOSWARE/pg_idkit","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/VADOSWARE/pg_idkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VADOSWARE%2Fpg_idkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VADOSWARE%2Fpg_idkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VADOSWARE%2Fpg_idkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VADOSWARE%2Fpg_idkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VADOSWARE","download_url":"https://codeload.github.com/VADOSWARE/pg_idkit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VADOSWARE%2Fpg_idkit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265527541,"owners_count":23782480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postgresql"],"created_at":"2024-08-06T08:03:08.547Z","updated_at":"2025-07-16T17:30:39.385Z","avatar_url":"https://github.com/VADOSWARE.png","language":"Dockerfile","funding_links":[],"categories":["Rust","Dockerfile"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  🐘 🪪 `pg_idkit`\n\u003c/h1\u003e\n\n```\npostgres=# CREATE EXTENSION pg_idkit;\nCREATE EXTENSION\n\npostgres=# SELECT idkit_uuidv7_generate();\n        idkit_uuidv7_generate\n--------------------------------------\n 018c106f-9304-79bb-b5be-4483b92b036c\n```\n\n## Description\n\n`pg_idkit` is a [Postgres][postgres] extension for generating many popular types of identifiers:\n\n| Methodology               | Function                                    | Crate                                | Description                                              |\n|---------------------------|---------------------------------------------|--------------------------------------|----------------------------------------------------------|\n| [UUID v6][uuidv6]         | `idkit_uuidv6_generate()`                   | [`uuidv6`][crate-uuidv6]             | UUID v6 ([RFC 4122][rfc-4122-update])                    |\n|                           | `idkit_uuidv6_generate_uuid()`              |                                      |                                                          |\n|                           | `idkit_uuidv6_extract_timestamptz(TEXT)`    |                                      |                                                          |\n| [UUID v7][uuidv7]         | `idkit_uuidv7_generate()`                   | [`uuid7`][crate-uuid7]               | UUID v7 ([RFC 4122][rfc-4122-update])                    |\n|                           | `idkit_uuidv7_generate_uuid()`              |                                      |                                                          |\n|                           | `idkit_uuidv7_extract_timestamptz(TEXT)`    |                                      |                                                          |\n| [nanoid][nanoid]          | `idkit_nanoid_generate()`                   | [`nanoid`][crate-nanoid]             | NanoID, developed by [Andrey Sitnik][github-ai]          |\n|                           | `idkit_nanoid_custom_generate_text()`       | [`nanoid`][crate-nanoid]             | NanoID with a custom length and alphabet                 |\n| [ksuid][ksuid]            | `idkit_ksuid_generate()`                    | [`svix-ksuid`][crate-svix-ksuid]     | Created by [Segment][segment]                            |\n|                           | `idkit_ksuid_extract_timestamptz(TEXT)`     |                                      |                                                          |\n|                           | `idkit_ksuidms_generate()`                  | [`svix-ksuid`][crate-svix-ksuid]     | Same as `ksuid` but with millisecond precision           |\n|                           | `idkit_ksuidms_extract_timestamptz(TEXT)`   |                                      |                                                          |\n| [ulid][ulid]              | `idkit_ulid_generate()`                     | [`ulid`][crate-ulid]                 | Unique, lexicographically sortable identifiers           |\n|                           | `idkit_ulid_extract_timestamptz(TEXT)`      |                                      |                                                          |\n| [Timeflake][timeflake]    | `idkit_timeflake_generate()`                | [`timeflake-rs`][crate-timeflake-rs] | Twitter's Snowflake + Instagram's ID + Firebase's PushID |\n|                           | `idkit_timeflake_extract_timestamptz(TEXT)` |                                      |                                                          |\n| [PushID][pushid]          | `idkit_pushid_generate()`                   | [`pushid`][crate-pushid]             | Google Firebase's PushID                                 |\n| [xid][xid]                | `idkit_xid_generate()`                      | [`xid`][crate-xid]                   | XID                                                      |\n|                           | `idkit_xid_extract_timestamptz(TEXT)`       |                                      |                                                          |\n| [cuid][cuid] (deprecated) | `idkit_cuid_generate()`                     | [`cuid`][crate-cuid]                 | CUID                                                     |\n|                           | `idkit_cuid_extract_timestamptz(TEXT)`      |                                      |                                                          |\n| [cuid2][cuid2]            | `idkit_cuid2_generate()`                    | [`cuid2`][crate-cuid2]               | CUID2                                                    |\n|                           | `idkit_cuid2_generate_with_len(length)`     |                                      | CUID2 with custom length                                |\n\nThis Postgres extension is made possible thanks to [`pgrx`][pgrx].\n\n[crate-uuidv6]: https://crates.io/crates/uuidv6\n[crate-uuid7]: https://crates.io/crates/uuid7\n[crate-nanoid]: https://crates.io/crates/nanoid\n[crate-svix-ksuid]: https://crates.io/crates/svix-ksuid\n[crate-svix-ksuid]: https://crates.io/crates/svix-ksuid\n[crate-ulid]: https://crates.io/crates/ulid\n[crate-timeflake-rs]: https://crates.io/crates/timeflake-rs\n[crate-pushid]: https://crates.io/crates/pushid\n[crate-xid]: https://crates.io/crates/xid\n[crate-cuid]: https://crates.io/crates/cuid\n[crate-cuid2]: https://crates.io/crates/cuid2\n\n## Quickstart\n\nYou can try out `pg_idkit` incredibly quickly by using `docker`, and a previously [released package of `pg_idkit`][released-packages]:\n\n```console\ndocker run \\\n    --rm \\\n    -e POSTGRES_PASSWORD=replace_this \\\n    -p 5432 \\\n    --name pg_idkit \\\n    ghcr.io/vadosware/pg_idkit:0.3.0-pg17.5-alpine3.21.3-amd64\n```\n\n\u003e [!WARNING]\n\u003e Currently only amd64 (x86_64) images are present/supported (See [`pg_idkit` packages][released-packages]).\n\u003e\n\u003e Work to support more platforms is described in [issue #30](https://github.com/VADOSWARE/pg_idkit/issues/30)\n\nOnce the postgres server is running, open another shell and connect to the dockerized Postgres instance running on port `5432`:\n\n```console\n➜ docker exec -it pg_idkit psql -U postgres\npsql (17.5)\nType \"help\" for help.\n\npostgres=# CREATE EXTENSION pg_idkit;\nCREATE EXTENSION\n\npostgres=# SELECT idkit_uuidv7_generate();\n        idkit_uuidv7_generate\n--------------------------------------\n 018c106f-9304-79bb-b5be-4483b92b036c\n(1 row)\n```\n\n## Installing `pg_idkit`\n\n\u003cdetails\u003e\n\u003csummary\u003e📃 From Source\u003c/summary\u003e\n\n### Source install\n\nTo build `pg_idkit` from source, clone this repository and run the following:\n\n```console\ncargo install cargo-get cargo-pgrx just\njust package\n```\n\nAfter running these commands you should see the following directory structure in `target/release/pg_idkit-pg17`:\n\n```\ntarget/release/pg_idkit-pg16\n├── home\n│   └── \u003cuser\u003e\n│       └── .pgrx\n│           └── 17.5\n│               └── pgrx-install\n│                   ├── lib\n│                   │   └── postgresql\n│                   │       └── pg_idkit.so\n│                   └── share\n│                       └── postgresql\n│                           └── extension\n│                               ├── pg_idkit--0.3.0.sql\n│                               └── pg_idkit.control\n└── usr\n    ├── lib\n    │   └── postgresql\n    │       └── pg_idkit.so\n    └── share\n        └── postgresql\n            └── extension\n                └── pg_idkit.control\n\n24 directories, 8 files\n```\n\nAs 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.\n\nIn the example above, the [files you need for a Postgres extension][pg-ext-files] are:\n\n- `target/release/home/\u003cuser\u003e/.pgrx/17.5/pgrx-install/lib/postgresql/pg_idkit.so`\n- `target/release/home/\u003cuser\u003e/.pgrx/17.5/pgrx-install/share/postgresql/extension/pg_idkit--0.3.0.sql`\n- `target/release/home/\u003cuser\u003e/.pgrx/17.5/pgrx-install/share/postgresql/extension/pg_idkit.control`\n\nInstall 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.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e💽 From Binary\u003c/summary\u003e\n\n### Binary install\n\nIf 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](/releases), and add it as one of your `shared_preload_libraries` in `postgresql.conf`.\n\nAssuming you have downloaded the `pg_idkit-vX.X.X.so` file to `/etc/postgresql/extensions`, you might change the file like this:\n\n`postgresql.conf`\n```\nshared_preload_libraries = '/etc/postgresql/extensions/pg_idkit-vX.X.X.so'\n```\n\nOnce your postgres instance is started up, you should be able to `CREATE EXTENSION`:\n\n```\npostgres=# CREATE EXTENSION pg_idkit;\nCREATE EXTENSION\npostgres=# SELECT idkit_uuidv7_generate();\n        idkit_uuidv7_generate\n--------------------------------------\n 018c106f-9304-79bb-b5be-4483b92b036c\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e🐳 Dockerfile\u003c/summary\u003e\n\n### Dockerfile\n\nTo use `pg_idkit` easily from a containerized environment, you can use the `pg_idkit` image, built from [`postgres`][docker-postgres]:\n\n```console\ndocker run \\\n    --rm \\\n    -e POSTGRES_PASSWORD=replace_this \\\n    -p 5432 \\\n    --name pg_idkit \\\n    ghcr.io/vadosware/pg_idkit:0.3.0-pg17.5-alpine3.18-amd64\n```\n\nFrom another terminal, you can exec into the `pg_idkit` container and enable `pg_idkit`:\n\n```console\n➜ docker exec -it pg_idkit psql -U postgres\npsql (17.5)\nType \"help\" for help.\n\npostgres=# CREATE EXTENSION pg_idkit;\nCREATE EXTENSION\npostgres=# SELECT idkit_uuidv7_generate();\n        idkit_uuidv7_generate\n--------------------------------------\n 018c106f-9304-79bb-b5be-4483b92b036c\n(1 row)\n```\n\n\u003e [!WARNING]\n\u003e Currently only amd64 (x86_64) images are present/supported (See [`pg_idkit` packages][released-packages]).\n\u003e\n\u003e Work to support more platforms is described in [issue #30](https://github.com/VADOSWARE/pg_idkit/issues/30)\n\n[docker-postgres]: https://hub.docker.com/_/postgres\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e📦 Debian (RPM)\u003c/summary\u003e\n\n### RPM install\n\nRPMs are produced upon [every official release](/releases) of `pg_idkit`.\n\nGrab a released version of the RPM (or build one yourself by running `just build-rpm` after [setting up local development][guide-localdev]).\n\nFor example, with an RPM named `pg_idkit-0.3.0-pg17.x86_64.rpm`, you should be able to run:\n\n```\ndnf install pg_idkit-0.3.0-pg17.x86_64.rpm\n```\n\n\u003c/details\u003e\n\n## Prior Art\n\nThere are some other projects in the Postgres ecosystem that implement alternative UUID generation mechanisms.\n\nHere are some you may or may not have heard of:\n\n- [spa5k/uids-postgres](https://github.com/spa5k/uids-postgres)\n- [`scoville/pgsql-ulid`](https://github.com/scoville/pgsql-ulid)\n- [`pg-xid`](https://github.com/modfin/pg-xid)\n- [`geckoboard/pgulid`](https://github.com/geckoboard/pgulid)\n- [this gist by `fabiolimace` for generating UUIDv6](https://gist.github.com/fabiolimace/515a0440e3e40efeb234e12644a6a346)\n\n## Setting up for local development\n\nInterested in contributing on the project? Set up your local development environment w/ [`docs/local-development.md`][guide-localdev].\n\n## Contributing\n\nContributions are welcome!\n\nIf you find a bug or an impovement that should be included in `pg_idkit`, [create an issue](https://github.com/vadosware/pg_idkit/issues).\n\nIf you'd like to contribute code, get started by:\n\n1. Reading the [local development guide][guide-localdev]\n2. Creating an issue (if necessary) to explain the new feature/bugfix/etc\n3. Forking this repository\n4. Creating a feature/bugfix/etc branch  (we expect [conventional commits][conventional-commits], i.e. `feat: new awesome feature`)\n5. Opening a Pull Request to this repository\n\n## FAQ/Common Issues\n\n### Error: `pgXX` is not managed by pgrx\n\nIf you find this, you're likely using a version of [`cargo-pgrx`][cargo-pgrx] that is too old.\n\n```console\ncargo install --locked cargo-pgrx\n```\n\n[a-chilton]: https://github.com/chilts\n[a-feerasta]: https://github.com/alizain\n[cargo-get]: https://crates.io/crates/cargo-get\n[cargo-pgrx]: https://crates.io/crates/cargo-pgrx\n[cargo-watch]: https://github.com/passcod/cargo-watch\n[cuid2]: https://github.com/paralleldrive/cuid2\n[cuid]: https://github.com/paralleldrive/cuid\n[direnv]: https://direnv.net\n[docker]: https://docs.docker.com/get-started/overview/\n[e-elliott]: https://github.com/ericelliott\n[git-crypt]: https://github.com/AGWA/git-crypt\n[github-ai]: https://github.com/ai\n[google]: https://google.com\n[instagram]: instagram-engineering.com/\n[it-cabrera]: https://darkghosthunter.medium.com/\n[just]: https://github.com/casey/just\n[ksuid]: https://github.com/segmentio/ksuid\n[mongodb]: https://www.mongodb.com/blog/channel/engineering-blog\n[nanoid]: https://www.npmjs.com/package/nanoid\n[o-poitrey]: https://github.com/rs\n[objectid]: https://www.mongodb.com/docs/manual/reference/method/ObjectId/\n[oryx-pro]: https://system76.com/laptops/oryx\n[p-pearcy]: https://github.com/ppearcy/elasticflake\n[pg-docs-operator-classes]: https://www.postgresql.org/docs/current/indexes-opclass.html\n[pg-ext-files]: https://www.postgresql.org/docs/current/extend-extensions.html#EXTEND-EXTENSIONS-FILES\n[pgstattuple]: https://www.postgresql.org/docs/current/pgstattuple.html\n[postgres]: https://postgresql.org\n[pushid]: https://firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html\n[r-tallent]: https://github.com/richardtallent\n[repo]: https://github.com/t3hmrman/pg_idkit\n[rfc-4122-update]: https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-04\n[rust]: https://rust-lang.org\n[rustup]: https://rust-lang.github.io/rustup\n[segment]: https://segment.com/blog/engineering/\n[sony]: https://github.com/sony\n[t-pawlak]: https://github.com/T-PWK\n[timeflake]: https://github.com/anthonynsimon/timeflake\n[twitter-snowflake]: https://blog.twitter.com/engineering/en_us/a/2010/announcing-snowflake\n[twitter]: https://blog.twitter.com/engineering\n[ulid]: https://github.com/ulid/spec\n[uuidv1]: https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)\n[uuidv6]: https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-01.html\n[uuidv7]: https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-01.html\n[wiki-gregorian]: https://en.wikipedia.org/wiki/Gregorian_calendar\n[wiki-mac-address]: https://en.wikipedia.org/wiki/MAC_address\n[wiki-uuid]: https://en.wikipedia.org/wiki/Universally_unique_identifier\n[xid]: https://github.com/rs/xid\n[released-packages]: https://github.com/VADOSWARE/pg_idkit/pkgs/container/pg_idkit\n[guide-localdev]: ./docs/local-development.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVADOSWARE%2Fpg_idkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FVADOSWARE%2Fpg_idkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FVADOSWARE%2Fpg_idkit/lists"}