]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
[harmony] Bug 1634711: Backport Bug 1526703 from 5.0.6 - Increase the size of the...
authorDave Miller <justdave@bugzilla.org>
Tue, 14 May 2024 06:29:09 +0000 (02:29 -0400)
committerGitHub <noreply@github.com>
Tue, 14 May 2024 06:29:09 +0000 (02:29 -0400)
Bugzilla/DB/Schema.pm
Bugzilla/Install/DB.pm
extensions/FlagTypeComment/Extension.pm
extensions/Review/Extension.pm

index dc824107df608f2e074f50f631e7dd31ccdeb83c..a11b9639acacc20a30c5128e10718516bde713ea 100644 (file)
@@ -658,7 +658,7 @@ use constant ABSTRACT_SCHEMA => {
     FIELDS => [
       id      => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
       type_id => {
-        TYPE       => 'INT2',
+        TYPE       => 'INT3',
         NOTNULL    => 1,
         REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
       },
@@ -694,7 +694,7 @@ use constant ABSTRACT_SCHEMA => {
   # "flagtypes" defines the types of flags that can be set.
   flagtypes => {
     FIELDS => [
-      id               => {TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
+      id               => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
       name             => {TYPE => 'varchar(50)', NOTNULL => 1},
       description      => {TYPE => 'MEDIUMTEXT',  NOTNULL => 1},
       cc_list          => {TYPE => 'varchar(200)'},
@@ -721,7 +721,7 @@ use constant ABSTRACT_SCHEMA => {
   flaginclusions => {
     FIELDS => [
       type_id => {
-        TYPE       => 'INT2',
+        TYPE       => 'INT3',
         NOTNULL    => 1,
         REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
       },
@@ -743,7 +743,7 @@ use constant ABSTRACT_SCHEMA => {
   flagexclusions => {
     FIELDS => [
       type_id => {
-        TYPE       => 'INT2',
+        TYPE       => 'INT3',
         NOTNULL    => 1,
         REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
       },
index 65ef9913aebc0734ed44181491d5ae68b4e66bfa..5ee99dcf478528f583978695c03afd08df474a19 100644 (file)
@@ -483,9 +483,8 @@ sub update_table_definitions {
   $dbh->bz_drop_column('profiles', 'refreshed_when');
   $dbh->bz_drop_column('groups',   'last_changed');
 
-  # 2006-08-06 LpSolit@gmail.com - Bug 347521
-  $dbh->bz_alter_column('flagtypes', 'id',
-    {TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1});
+  # 2019-01-31 dylan@hardison.net - Bug TODO
+  _update_flagtypes_id();
 
   $dbh->bz_alter_column('keyworddefs', 'id',
     {TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1});
@@ -906,6 +905,30 @@ sub _update_product_name_definition {
   }
 }
 
+sub _update_flagtypes_id {
+  my $dbh   = Bugzilla->dbh;
+  my @fixes = (
+    {table => 'flaginclusions', column => 'type_id'},
+    {table => 'flagexclusions', column => 'type_id'},
+    {table => 'flags',          column => 'type_id'},
+  );
+  my $flagtypes_def = $dbh->bz_column_info('flagtypes', 'id');
+  foreach my $fix (@fixes) {
+    my $def = $dbh->bz_column_info($fix->{table}, $fix->{column});
+    if ($def->{TYPE} eq 'INT2') {
+      warn "Dropping foreign keys on $fix->{table}\n";
+      $dbh->bz_drop_related_fks($fix->{table}, $fix->{column});
+      $def->{TYPE} = 'INT3';
+      $dbh->bz_alter_column($fix->{table}, $fix->{column}, $def);
+    }
+  }
+
+  if ($flagtypes_def->{TYPE} eq 'SMALLSERIAL') {
+    $flagtypes_def->{TYPE} = 'MEDIUMSERIAL';
+    $dbh->bz_alter_column('flagtypes', 'id', $flagtypes_def);
+  }
+}
+
 # A helper for the function below.
 sub _write_one_longdesc {
   my ($id, $who, $when, $buffer) = (@_);
index fabbb9bee8d32c3a34c2a8ca70308332c263f302..9cb0e7fcb42a5ced2a975889149c3e1a7eeb3098 100644 (file)
@@ -42,7 +42,7 @@ sub db_schema_abstract_schema {
   $args->{'schema'}->{'flagtype_comments'} = {
     FIELDS => [
       type_id => {
-        TYPE       => 'INT2',
+        TYPE       => 'INT3',
         NOTNULL    => 1,
         REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
       },
@@ -53,6 +53,19 @@ sub db_schema_abstract_schema {
   };
 }
 
+sub install_update_db {
+  my $dbh   = Bugzilla->dbh;
+
+  # Bug 1634711 - justdave@bugzilla.org
+  my $def = $dbh->bz_column_info('flagtype_comments', 'type_id');
+  if ($def->{TYPE} eq 'INT2') {
+    warn "Dropping foreign keys on flagtype_comments\n";
+    $dbh->bz_drop_related_fks('flagtype_comments', 'type_id');
+    $def->{TYPE} = 'INT3';
+    $dbh->bz_alter_column('flagtype_comments', 'type_id', $def);
+  }
+}
+
 #############
 # Templates #
 #############
index fa4900ff2a3a154e70e195068b73bdadbb0ee7f1..45ee8b0cb3f0806c9fd2e4ff51b6f19ab1d0cda6 100644 (file)
@@ -856,7 +856,7 @@ sub db_schema_abstract_schema {
       flag_when => {TYPE => 'DATETIME', NOTNULL => 1,},
 
       type_id => {
-        TYPE       => 'INT2',
+        TYPE       => 'INT3',
         NOTNULL    => 1,
         REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
       },
@@ -954,6 +954,15 @@ sub install_update_db {
 
   # Bug 1588221 - dkl@mozilla.com
   $dbh->bz_alter_column('flag_state_activity', 'attachment_id', {TYPE => 'INT5'});
+
+  # Bug 1634711 - justdave@bugzilla.org
+  my $def = $dbh->bz_column_info('flag_state_activity', 'type_id');
+  if ($def->{TYPE} eq 'INT2') {
+    warn "Dropping foreign keys on flag_state_activity\n";
+    $dbh->bz_drop_related_fks('flag_state_activity', 'type_id');
+    $def->{TYPE} = 'INT3';
+    $dbh->bz_alter_column('flag_state_activity', 'type_id', $def);
+  }
 }
 
 sub install_filesystem {