Skip to content

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

Merged
taylorotwell merged 1 commit into
laravel:masterfrom
staudenmeir:uuid-v7
Aug 16, 2024
Merged

[12.x] Switch models to UUID v7#52433
taylorotwell merged 1 commit into
laravel:masterfrom
staudenmeir:uuid-v7

Conversation

@staudenmeir

Copy link
Copy Markdown
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
Copy Markdown
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?

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