-
Notifications
You must be signed in to change notification settings - Fork 680
Drop Email column (merge and deploy the fix for #1888 first!) #1891
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
Conversation
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @carols10cents (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
789892f to
521beb7
Compare
|
How should the |
5be765d to
afa3641
Compare
Removing the users.email line from the dump-db.toml file should do it. The dump-db.toml file is configuration for the public database dumps we make, and this test ensures the database schema is always in sync with this configuration so that we don't accidentally leak data. I'll make the error message for that test a bit clearer to point at what needs to be done. |
afa3641 to
3544b91
Compare
- `do_nothing` on `emails` insertion violates unique constraint on `user_id`
|
Thanks @carols10cents! That sorted it out. crates.io/migrations/20170804200817_add_email_table/up.sql Lines 16 to 17 in 23f187a
|
I'm confused, are you getting a unique key violation? Can you give me steps to reproduce? |
|
Oh I see the errors in travis now. Investigating! |
carols10cents
left a comment
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.
Some comments that should help you get past the test failures! Please let me know if you have more questions!
| @@ -0,0 +1,2 @@ | |||
| -- Your SQL goes here | |||
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.
You can remove this comment :)
| @@ -0,0 +1,2 @@ | |||
| -- Your SQL goes here | |||
| ALTER TABLE users DROP COLUMN email CASCADE; | |||
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.
This is super picky, but can you remove the extra space between TABLE and users?
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.
:)
src/controllers/user/me.rs
Outdated
| let verified = verified.unwrap_or(false); | ||
| let verification_sent = verified || verification_sent; | ||
| let user = User { email, ..user }; | ||
| let user = User { ..user }; |
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 this line can be completely removed now, actually! I think user = User { ..user } is doing a no-op.
src/models/user.rs
Outdated
| email_verified: bool, | ||
| email_verification_sent: bool, | ||
| ) -> EncodablePrivateUser { | ||
| ) -> CargoResult<EncodablePrivateUser> { |
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.
Can you explain why this function needed to be changed to return a Result? It doesn't look like it's necessary to me because I don't see anywhere returning an Err variant. Am I missing something?
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.
It isn't necessary. I was previously reading this email variable from the database with an Err
Line 86 in 3544b91
| if let Some(user_email) = email { |
variant result before realizing that was already "done" and the email could simply be passed to the src/models/users/encodable_private function as an argument.
I definitely forgot to undo that modification to the return type - will do so now
src/models/user.rs
Outdated
| pub gh_id: i32, | ||
| } | ||
|
|
||
| /// Represents a new user record insertible to the `users` 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.
Small fix: can you change insertible to insertable in this comment please?
src/tests/util.rs
Outdated
| user.email = Some(email.to_string()); | ||
| let email = "[email protected]"; | ||
| let user = crate::new_user(username) | ||
| .create_or_update(Some(email), conn) |
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.
Aha, so the unique constraint that's causing the tests to fail is that here in the test setup you're creating a new user with an email set, then lines 142-149 right after this the test setup is inserting the email into the table directly, which violates the constraint we have that each user may only have one email.
To fix this, you can pass None to create_or_update here and the next part will take care of inserting the email (and setting it to verified, which is important for the tests).
f74d1ff to
3be2b55
Compare
- retain email registered with when github email is modified
carols10cents
left a comment
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.
Just one question, thanks!
src/tests/user.rs
Outdated
|
|
||
| // Simulate logging in via GitHub. Don't use app.db_new_user because it inserts a verified | ||
| // email directly into the database and we want to test the verification flow here. | ||
| let email = "cow@mammals@milk"; |
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'm curious, why is the value different here? Any particular reason, and any reason why it's not a valid email address (two @s)?
|
Resolved. The invalid email address was a mistake I hadn't noted |
|
Thank you so much!! This looks great, but I'm not going to merge it yet-- we need to merge and deploy the fix for #1888 to remove all the uses of the email column first, so that there aren't any connections using the |
|
☔ The latest upstream changes (presumably #1901) made this pull request unmergeable. Please resolve the merge conflicts. |
Missed a conversion from UserNoEmailType to User When reviewing #1911, I missed a spot. I reverted the PR merge on master, so this PR reverts the revert and adds the fix. I tried to write a test that would have caught this, but I utterly failed at making a real-enough app/request that would have `.user()` but would let me set the `session()` :( Also a lot of this code is temporary and will be undone once I've rebased #1891, but this needs to be deployed separately from #1891 to ensure there aren't any uses of the email column. r? @jtgeibel
f400318 to
8a8a1d3
Compare
|
☔ The latest upstream changes (presumably #1700) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I removed some more of the temporary code that was needed to deploy the code that stopped using the email column (and that has been deployed). I also introduced more merge conflicts by merging another PR just now; I'll be fixing those in a few hours. |
|
I think this is ready to go now!! Thank you!!! @bors r+ |
|
📌 Commit c7ac5cb has been approved by |
|
☀️ Test successful - checks-travis |
Fixes #1889
This cleans up the uses of the field
emailfromUserby:emailfield fromUser