Always store primary email address into email_address table and also the state #15956

Merged
lunny merged 18 commits from lunny/email_address into main 2021-06-08 03:52:51 +00:00
Owner

This PR will always store primary email address into email_address table and also add is_primary column on that table.

Replace #13296 and fix #11251 and #10279

TODO: (next PRs)

  • Remove column email from user table
This PR will always store primary email address into email_address table and also add `is_primary` column on that table. Replace #13296 and fix #11251 and #10279 TODO: (next PRs) - [ ] Remove column `email` from `user` table
lafriks (Migrated from github.com) reviewed 2021-05-23 12:24:43 +00:00
lafriks (Migrated from github.com) commented 2021-05-23 12:24:43 +00:00
Author
Owner

wouldn't before update/insert hook be better?

wouldn't before update/insert hook be better?
zeripath reviewed 2021-06-04 16:43:23 +00:00
@ -0,0 +46,4 @@
// change lower_email as unique
if err = x.Sync2(new(EmailAddress)); err != nil {
return
}
Contributor

I'm not sure that the unique constraint will definitely get set here on every db.

I'm not sure that the unique constraint will definitely get set here on every db.
zeripath reviewed 2021-06-04 16:43:56 +00:00
@ -0,0 +9,4 @@
"xorm.io/xorm"
)
func addPrimaryEmail2EmailAddress(x *xorm.Engine) (err error) {
Contributor

We need a testcase for this.

We need a testcase for this.
zeripath reviewed 2021-06-04 16:45:18 +00:00
Contributor

u.Email = strings.ToLower(u.Email) at line 878

u.Email = strings.ToLower(u.Email) at line 878
zeripath reviewed 2021-06-04 16:51:50 +00:00
Contributor

It does appear that EmailAddress isn't doing this lowercasing so perhaps we need to do something about not lowercasing before we stick things into EmailAddress even if we have to lowercase in User.

It does appear that EmailAddress isn't doing this lowercasing so perhaps we need to do something about not lowercasing before we stick things into EmailAddress even if we have to lowercase in User.
lunny reviewed 2021-06-05 02:00:09 +00:00
@ -0,0 +46,4 @@
// change lower_email as unique
if err = x.Sync2(new(EmailAddress)); err != nil {
return
}
Author
Owner

It's a work of xorm to translate it to database's syntax.

It's a work of `xorm` to translate it to database's syntax.
lunny reviewed 2021-06-05 02:18:33 +00:00
Author
Owner

Done. Since user's email will be removed in next PRs, I think we can keep it there in this PR.

Done. Since user's email will be removed in next PRs, I think we can keep it there in this PR.
lunny reviewed 2021-06-05 02:18:42 +00:00
@ -0,0 +9,4 @@
"xorm.io/xorm"
)
func addPrimaryEmail2EmailAddress(x *xorm.Engine) (err error) {
Author
Owner

Added

Added
zeripath reviewed 2021-06-05 10:24:08 +00:00
@ -0,0 +46,4 @@
// change lower_email as unique
if err = x.Sync2(new(EmailAddress)); err != nil {
return
}
Contributor

cool. Just checked!

cool. Just checked!
zeripath reviewed 2021-06-05 10:30:20 +00:00
Contributor

should these be lower too?

	SearchEmailOrderByEmail        SearchEmailOrderBy = "email_address.lower_email ASC, email_address.is_primary DESC, email_address.id ASC"
	SearchEmailOrderByEmailReverse SearchEmailOrderBy = "email_address.lower_email DESC, email_address.is_primary ASC, email_address.id DESC"
should these be lower too? ```suggestion SearchEmailOrderByEmail SearchEmailOrderBy = "email_address.lower_email ASC, email_address.is_primary DESC, email_address.id ASC" SearchEmailOrderByEmailReverse SearchEmailOrderBy = "email_address.lower_email DESC, email_address.is_primary ASC, email_address.id DESC" ```
Contributor

Should this be lower too?

			builder.Like{"email_address.lower_email", likeStr},
Should this be lower too? ```suggestion builder.Like{"email_address.lower_email", likeStr}, ```
lunny reviewed 2021-06-05 10:51:45 +00:00
Author
Owner

Done.

Done.
lunny reviewed 2021-06-05 10:51:50 +00:00
Author
Owner

Done.

Done.
zeripath approved these changes 2021-06-05 13:34:50 +00:00
lafriks (Migrated from github.com) approved these changes 2021-06-05 16:30:43 +00:00
This repo is archived. You cannot comment on pull requests.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lunny/gitea#15956
No description provided.