Skip to content
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

[12.x] Switch models to UUID v7 #52433

Merged
merged 1 commit into from
Aug 16, 2024
Merged

Conversation

staudenmeir
Copy link
Contributor

Based on #52029, I'm proposing to switch the HasUuids trait to UUID v7.

This change is similar to the reverted #44210 but addresses its privacy concerns: While #44210 switched all UUIDs to v7, this PR only targets model UUIDs and they already contain a timestamp in the current implementation.

v7 is a standardized format, while the UUIDs generated by Str::orderedUuid() at the moment are only a custom variant of the v4 standard.

At least on PostgreSQL, v7 UUIDs also seem to perform much better.

Upgrade

This is a breaking change for users of the trait that rely on the sortability of UUIDs. The affected models need to continue generating UUIDs with Str::orderedUuid(). I added a legacy HasVersion4Uuids trait because that's the most convenient solution, IMO.

I removed the HasVersion7Uuids trait from #52029 because it's redundant now. We could also deprecate it and remove it later.

@taylorotwell
Copy link
Member

It seems like that Postgres tweet is referring to unsorted v4 UUIDs. I'm not sure sorted V4 to sorted V7 migration would show same performance gains?

@taylorotwell taylorotwell merged commit c50ee30 into laravel:master Aug 16, 2024
31 checks passed
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