Skip to content

Add UUIDv7 as default record primary key #951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ezekg
Copy link
Member

@ezekg ezekg commented May 14, 2025

Should improve performance and risk in using batch operations like find_each using the default of sorting by primary key.

Prereqs

  • Talk to customers and make sure this won't be a breaking change, e.g. if a customer is expecting UUIDv4s, this would break that expectation — even if we have always reserved the right to change the format of new resource identifiers.

@ezekg ezekg force-pushed the feature/add-uuidv7-primary-keys branch 2 times, most recently from c7b2dfb to 884f7dd Compare May 14, 2025 13:53
@seuros
Copy link

seuros commented May 16, 2025

You can use ulid, it cleaner and you can prefix it.
Here is a gem i build for it : https://github.com/seuros/activerecord-ulid

@ezekg
Copy link
Member Author

ezekg commented May 16, 2025

@seuros our Postgres primary keys are UUIDs, so that won't work. Changing primary key type is infeasible.

Also: https://github.com/rafaelsales/ulid#-please-hold-on

@seuros
Copy link

seuros commented May 16, 2025

In that case, yes.

@ezekg ezekg force-pushed the feature/add-uuidv7-primary-keys branch from 884f7dd to 2f0be1c Compare May 16, 2025 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants