fix(models): generate uuid v7 keys - #5
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With key_type set to uuid, CustomField and CustomFieldValue filled their key in the creating hook with Str::uuid(), a random UUID v4. Hosts that key their own models with HasUuids get UUID v7 from Laravel, so the package rows were the only ones in the schema whose keys carried no time ordering: they sort randomly, fragment the primary key index on insert, and break the convention of an application that uses v7 everywhere.
Both hooks now call Str::uuid7(). The ulid branch and the id default are untouched, and the column type does not change, so existing v4 keys stay valid and no migration is needed. Str::uuid7() is available on both supported illuminate/support floors (12 and 13).
The uuid keyed host test in KeyTypeTest now also asserts the version nibble of both the definition key and the value key, so a regression to v4 fails the suite.
CHANGELOG gets the 0.1.1 entry and the README key_type row says that uuid generates UUID v7.