diff options
author | Tiago Mello <timello@gmail.com> | 2010-08-27 00:27:08 -0300 |
---|---|---|
committer | Tiago Mello <timello@gmail.com> | 2010-08-27 00:27:08 -0300 |
commit | 0844fe9fc6d2d5293fad1384d2955dedf30fc8c4 (patch) | |
tree | 636a0bbcdf71017fda712e60cd1a0dc1b7038b7b /Bugzilla/Install | |
parent | d94865b30a92be8a3a900f8d1d8262d36044b1ca (diff) | |
download | bugs-0844fe9fc6d2d5293fad1384d2955dedf30fc8c4.tar bugs-0844fe9fc6d2d5293fad1384d2955dedf30fc8c4.tar.gz bugs-0844fe9fc6d2d5293fad1384d2955dedf30fc8c4.tar.bz2 bugs-0844fe9fc6d2d5293fad1384d2955dedf30fc8c4.tar.xz bugs-0844fe9fc6d2d5293fad1384d2955dedf30fc8c4.zip |
Bug 479400: Add the ability to show or hide particular custom fields
based on multiple values of another field (visibility controllers)
r/a=mkanat
Diffstat (limited to 'Bugzilla/Install')
-rw-r--r-- | Bugzilla/Install/DB.pm | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index bfce7779f..b786e0624 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -88,7 +88,6 @@ sub update_fielddefs_definition { } $dbh->bz_add_column('fielddefs', 'visibility_field_id', {TYPE => 'INT3'}); - $dbh->bz_add_column('fielddefs', 'visibility_value_id', {TYPE => 'INT2'}); $dbh->bz_add_column('fielddefs', 'value_field_id', {TYPE => 'INT3'}); $dbh->bz_add_index('fielddefs', 'fielddefs_value_field_id_idx', ['value_field_id']); @@ -113,6 +112,9 @@ sub update_fielddefs_definition { $dbh->bz_add_index('fielddefs', 'fielddefs_is_mandatory_idx', ['is_mandatory']); + # 2010-04-05 dkl@redhat.com - Bug 479400 + _migrate_field_visibility_value(); + # Remember, this is not the function for adding general table changes. # That is below. Add new changes to the fielddefs table above this # comment. @@ -561,8 +563,6 @@ sub update_table_definitions { # 2008-09-07 LpSolit@gmail.com - Bug 452893 _fix_illegal_flag_modification_dates(); - _add_visiblity_value_to_value_tables(); - # 2009-03-02 arbingersys@gmail.com - Bug 423613 _add_extern_id_index(); @@ -3208,20 +3208,6 @@ sub _fix_illegal_flag_modification_dates { print "$rows flags had an illegal modification date. Fixed!\n" if ($rows =~ /^\d+$/); } -sub _add_visiblity_value_to_value_tables { - my $dbh = Bugzilla->dbh; - my @standard_fields = - qw(bug_status resolution priority bug_severity op_sys rep_platform); - my $custom_fields = $dbh->selectcol_arrayref( - 'SELECT name FROM fielddefs WHERE custom = 1 AND type IN(?,?)', - undef, FIELD_TYPE_SINGLE_SELECT, FIELD_TYPE_MULTI_SELECT); - foreach my $field (@standard_fields, @$custom_fields) { - $dbh->bz_add_column($field, 'visibility_value_id', {TYPE => 'INT2'}); - $dbh->bz_add_index($field, "${field}_visibility_value_id_idx", - ['visibility_value_id']); - } -} - sub _add_extern_id_index { my $dbh = Bugzilla->dbh; if (!$dbh->bz_index_info('profiles', 'profiles_extern_id_idx')) { @@ -3395,6 +3381,33 @@ sub _remove_attachment_isurl { } } +sub _migrate_field_visibility_value { + my $dbh = Bugzilla->dbh; + + if ($dbh->bz_column_info('fielddefs', 'visibility_value_id')) { + print "Populating new field_visibility table...\n"; + + $dbh->bz_start_transaction(); + + my %results = + @{ $dbh->selectcol_arrayref( + "SELECT id, visibility_value_id FROM fielddefs + WHERE visibility_value_id IS NOT NULL", + { Columns => [1,2] }) }; + + my $insert_sth = + $dbh->prepare("INSERT INTO field_visibility (field_id, value_id) + VALUES (?, ?)"); + + foreach my $id (keys %results) { + $insert_sth->execute($id, $results{$id}); + } + + $dbh->bz_commit_transaction(); + $dbh->bz_drop_column('fielddefs', 'visibility_value_id'); + } +} + 1; __END__ |