diff options
author | lpsolit%gmail.com <> | 2006-12-27 03:12:04 +0100 |
---|---|---|
committer | lpsolit%gmail.com <> | 2006-12-27 03:12:04 +0100 |
commit | f349f2bd347c7836d622a9afe51663fda50c21d5 (patch) | |
tree | 0fab364a3fa5c67ae1b95edadc5c7b7e280506c0 /contrib | |
parent | 873c5b69e8fc21ae84898fdccd8bb91a35184fb2 (diff) | |
download | bugzilla-f349f2bd347c7836d622a9afe51663fda50c21d5.tar.gz bugzilla-f349f2bd347c7836d622a9afe51663fda50c21d5.tar.xz |
Bug 364134: Upgrading from 2.20 to latest CVS produces error message in contrib/recode.pl - Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=bkor a=justdave
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/recode.pl | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/contrib/recode.pl b/contrib/recode.pl index 10a4cbb44..741c62e2a 100755 --- a/contrib/recode.pl +++ b/contrib/recode.pl @@ -47,6 +47,15 @@ use constant SPECIAL_KEYS => { profile_setting => 'user_id,setting_name', profiles_activity => 'userid,profiles_when,fieldid', setting_value => 'name,value', + # longdescs didn't used to have a PK, before 2.20. + longdescs => 'bug_id,bug_when', + # The 2.16 versions table lacked a PK + versions => 'product_id,value', + # These are all for earlier versions of Bugzilla. On a modern + # version of Bugzilla, this script will ignore these (thanks to + # code further down). + components => 'program,value', + products => 'product', }; ############### @@ -192,13 +201,20 @@ foreach my $table ($dbh->bz_table_list_real) { my @columns = $dbh->bz_table_columns($table); my $pk = SPECIAL_KEYS->{$table}; + if ($pk) { + # Assure that we're on a version of Bugzilla where those keys + # actually exist. + foreach my $column (split ',', $pk) { + $pk = undef if !$dbh->bz_column_info($table, $column); + } + } # Figure out the primary key. foreach my $column (@columns) { my $def = $dbh->bz_column_info($table, $column); $pk = $column if $def->{PRIMARYKEY}; } - # If there's no PK, it's defined by the a UNIQUE index. + # If there's no PK, it's defined by a UNIQUE index. if (!$pk) { foreach my $column (@columns) { my $index = $dbh->bz_index_info($table, "${table}_${column}_idx"); @@ -213,6 +229,12 @@ foreach my $table ($dbh->bz_table_list_real) { my $def = $dbh->bz_column_info($table, $column); # If this is a text column, it may need work. if ($def->{TYPE} =~ /text|char/i) { + # If there's still no PK, we're upgrading from 2.14 or earlier. + # We can't reliably determine the PK (or at least, I don't want to + # maintain code to record what the PK was at all points in history). + # So instead we just use the field itself. + $pk = $column if !$pk; + print "Converting $table.$column...\n"; my $sth = $dbh->prepare("SELECT $column, $pk FROM $table WHERE $column IS NOT NULL |