-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add missing indices to resolve #1067 #1069
Conversation
I wasn't sure if you had a naming convention for indices. Please let me know if you would like me to update the names. To test the migrations, I applied them on both postgres and mysql using the supplied docker-compose setup. |
oauth2/fosite_store_sql.go
Outdated
@@ -87,6 +87,8 @@ func sqlSchemaUp(table string, id string) string { | |||
subject varchar(255) NOT NULL | |||
)`, | |||
"4": fmt.Sprintf("ALTER TABLE hydra_oauth2_%s ADD active BOOL NOT NULL DEFAULT TRUE", table), | |||
"5": fmt.Sprintf("CREATE INDEX hydra_oauth2_%s_request_id_idx ON hydra_oauth2_%s (request_id)", table, table), |
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.
I think it would make sense to have an unique index. They key should really be unique and it will help with query speed.
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.
Nice catch 👍
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.
lmao 2 years later and I found that this new unique index actually breaks OpenID Connect compliance...welp 🤷
}, | ||
}, | ||
{ | ||
Id: "6", |
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.
These two can be merged, no?
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.
@aeneasr I had to keep them separate because I only wanted to create an index on the requested_at
column on the hydra_oauth2_access
table.
I guess I could add a semicolon and add another statement to migration 5?
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.
Oh yeah, I see, this is because of the function design. Let's keep it the way you have it
Please also add a test. Since you didn't change the schema it's probably enough to re-enter the previous data again but with a new ID. |
@aeneasr maybe I am being stupid 😅, but I am not sure how adding the test to https://github.com/ory/hydra/blob/master/client/manager_0_sql_migrations_test.go will work? That test seems to be specifically around migrations related to the client manager? |
Thanks for the feedback! Will address in the morning 🙌 |
f9cb97a
to
2718474
Compare
• `request_id` column in the hydra_oauth2_access & hydra_oauth2_refresh tables • `requested_at` column in the hydra_oauth2_access table Signed-off-by: Amir Aslaminejad <[email protected]>
2718474
to
7ff3e53
Compare
Update:• Changed index to a unique index on the |
… on the request_id column Signed-off-by: Amir Aslaminejad <[email protected]>
Update• Fixed broken test - there was a test that was inserting multiple records with the same |
Nice! I'll review that tomorrow! |
…the `request_id` column in the hydra_oauth2_access and hydra_oauth2_refresh tables. Signed-off-by: Amir Aslaminejad <[email protected]>
d505fc2
to
2399d83
Compare
Update:• Added new test coverage to cover the unique constraints placed on the This PR is ready for potentially a final review @aeneasr 🤝 |
Thank you! |
Signed-off-by: Amir Aslaminejad <[email protected]>
Signed-off-by: Amir Aslaminejad <[email protected]>
See #1069 Signed-off-by: Amir Aslaminejad <[email protected]>
Resolves #1067 by adding indices to:
•
request_id
column in the hydra_oauth2_access & hydra_oauth2_refresh tables•
requested_at
column in the hydra_oauth2_access tableReview: @aeneasr