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
Making the verification and password reset token unqiue #15488
Merged
NoResponseMate
merged 5 commits into
Sylius:1.13
from
mamazu:index_on_password_reset_token
Nov 9, 2023
Merged
Making the verification and password reset token unqiue #15488
NoResponseMate
merged 5 commits into
Sylius:1.13
from
mamazu:index_on_password_reset_token
Nov 9, 2023
Conversation
This file contains 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
Bunnyshell Preview Environment deletedAvailable commands:
|
mamazu
force-pushed
the
index_on_password_reset_token
branch
from
November 3, 2023 00:43
21f87a7
to
052a759
Compare
diimpp
reviewed
Nov 3, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently unique index on nullable
field is a sort of grey zone, but which works for mysql. Is it confirmed to work with postgresql as well?
https://dba-presents.com/databases/mysql/274-mysql-unique-index-with-null-values
src/Sylius/Bundle/CoreBundle/Migrations/Version20231103004216.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/Migrations/Version20231103004216.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/Migrations/Version20231103004216.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/Migrations/Version20231103004216.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/UserBundle/Resources/config/doctrine/model/User.orm.xml
Outdated
Show resolved
Hide resolved
Co-authored-by: Dmitri Perunov <diimpp@gmail.com>
diimpp
approved these changes
Nov 3, 2023
diimpp
requested changes
Nov 3, 2023
src/Sylius/Bundle/UserBundle/Resources/config/doctrine/model/User.orm.xml
Outdated
Show resolved
Hide resolved
diimpp
approved these changes
Nov 3, 2023
NoResponseMate
approved these changes
Nov 4, 2023
Thank you, @mamazu! |
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.
The problem
Currently we have a user database of about 1 million users and we noticed that resetting your password is rather slow. It turns out that there isn't any index on neither the password reset nor the verification token.
The solution
The simplest solution would be to add an index to those fields and call it a day. But we can do even better. We know that those tokens are unique. Because all throughout the Sylius application those fields are queried with the
findOneBy
which crashes on result sets bigger than one. So adding a unique constraint should not break backwards compatibility (except for already broken entries).What still needs to be done
I still need to generate a migration that actually adds those indices to the database. I will do that when the base idea of the PR is accepted.