]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
fix for 61637: Code bit for upgrading from 2.5
authorcyeh%bluemartini.com <>
Thu, 1 Mar 2001 07:33:01 +0000 (07:33 +0000)
committercyeh%bluemartini.com <>
Thu, 1 Mar 2001 07:33:01 +0000 (07:33 +0000)
based on patch submitted by ehanson@talkware.net (Eric Hanson)
support for changes comments table to longdescs, but only if comments
table exists.

checksetup.pl

index 2be26451aa3a27ee74bdd35a94d897e2a34872c1..a23ba6a50e7c1f7ddd13913e0a21ae7aea5f3524 100755 (executable)
@@ -1446,6 +1446,22 @@ sub DropField ($$)
               DROP COLUMN $field");
 }
 
+# this uses a mysql specific command. 
+sub TableExists ($)
+{
+   my ($table) = @_;
+   my @tables;
+   my $dbtable;
+   my $exists = 0;
+   my $sth = $dbh->prepare("SHOW TABLES");
+   $sth->execute;
+   while ( ($dbtable) = $sth->fetchrow_array ) {
+      if ($dbtable eq $table) {
+         $exists = 1;
+      } 
+   } 
+   return $exists;
+}   
 
 $::regenerateshadow = 0;
 
@@ -2122,6 +2138,19 @@ if (!GetFieldDef('profiles', 'emailflags')) {
     AddField('profiles', 'emailflags', 'mediumtext');
 }
 
+# http://bugzilla.mozilla.org/show_bug.cgi?id=61637
+# upgrade older versions of bugzilla that have the old comments table
+if (&TableExists('comments')) {
+    RenameField ('comments', 'when', 'bug_when');
+    ChangeFieldType('comments', 'bug_id', 'mediumint not null');
+    ChangeFieldType('comments', 'who', 'mediumint not null');
+    ChangeFieldType('comments', 'bug_when', 'datetime not null');
+    RenameField('comments','comment','thetext');
+    # Here we rename comments to longdescs
+    $dbh->do("DROP TABLE longdescs");
+    $dbh->do("ALTER TABLE comments RENAME longdescs");
+}
+
 #
 # If you had to change the --TABLE-- definition in any way, then add your
 # differential change code *** A B O V E *** this comment.