From 3891b63a1eb52076337885487f251a10580a4a85 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Wed, 27 Apr 2016 18:50:13 +0200 Subject: Bug 218917 - Allow the login name to be different from the email address Original patch by Gervase Markham r=gerv a=dkl --- Bugzilla/Install/DB.pm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Bugzilla/Install/DB.pm') diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index a6ca1e90f..b7ca7c657 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -748,6 +748,10 @@ sub update_table_definitions { # 2015-12-16 LpSolit@gmail.com - Bug 1232578 _sanitize_audit_log_table(); + # 2016-04-27 wurblzap@gmail.com and gerv@gerv.net - Bug 218917 + # Split login_name into login_name and email columns + _split_login_and_email($old_params); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ @@ -3957,6 +3961,27 @@ sub _sanitize_audit_log_table { } } +sub _split_login_and_email { + my ($old_params) = (@_); + + my $dbh = Bugzilla->dbh; + $dbh->bz_add_column('profiles', 'email', + {TYPE => 'varchar(255)', NOTNULL => 1}, ''); + $dbh->do('UPDATE profiles SET email = login_name'); + + # This change obsoletes the 'emailsuffix' parameter. If it is in use, + # append it to all the values in the 'email' column. + my $suffix = $old_params->{'emailsuffix'}; + if ($suffix) { + $dbh->do('UPDATE profiles SET email = ' . $dbh->sql_string_concat('email', '?'), + undef, $suffix); + } + + $dbh->bz_add_index('profiles', 'profiles_email_idx', + {TYPE => 'UNIQUE', FIELDS => ['email']}); +} + + 1; __END__ -- cgit v1.2.3-24-g4f1b