Should Blueprint::uuid() have the option for making the column unique? #46679
Unanswered
cosmastech
asked this question in
Ideas
Replies: 1 comment 6 replies
-
Thanks for converting this to a discussion @driesvints |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
Didn't want to go down the rabbit hole of writing the code for this if it would just be rejected outright, but it seems like the Blueprint@uuid() method should have an argument to make the column unique.
I think for most developers, they see UUIDs as a big benefit for security, but when they aren't indexed at all, they require a full table scan. Nudging the developer to make the column unique has twofold benefits:
There are of course cases where uniqueness is not desired, which is why I'm suggesting an optional argument. To maintain backwards compatibility, the optional argument would default to false.
What I was thinking was:
I realize that it's as simple as a developer chaining a call to
unique()
after their column definition, but I think this pushes developers into better practices. I can't count how many times I have had to write a second migration (when queries were interminably slow on production) or migrate:fresh once I realized the column wasn't already unique.I'll happily add this to 10.x (or 11.x?), just don't want to waste my time for the PR to be closed, so I thought I would ask first.
If we were to go the 11.x route, I would suggest making the argument default to true and list it as an Impacting Change.
Steps To Reproduce:
Beta Was this translation helpful? Give feedback.
All reactions