]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1526703 - Increase the size of the flagtype id column (#176)
authorDave Miller <justdave@bugzilla.org>
Sat, 11 May 2024 18:15:19 +0000 (14:15 -0400)
committerGitHub <noreply@github.com>
Sat, 11 May 2024 18:15:19 +0000 (14:15 -0400)
Co-authored-by: Dylan William Hardison <dylan@hardison.net>
Bugzilla/DB/Schema.pm
Bugzilla/Install/DB.pm

index bacc9dc5dfc18434344512ffe6650b105229aa11..e9dfa1a3fe9e86247e98bf9e1482b4dbd11baa94 100644 (file)
@@ -630,7 +630,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'}
       },
@@ -666,7 +666,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)'},
@@ -693,7 +693,7 @@ use constant ABSTRACT_SCHEMA => {
   flaginclusions => {
     FIELDS => [
       type_id => {
-        TYPE       => 'INT2',
+        TYPE       => 'INT3',
         NOTNULL    => 1,
         REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
       },
@@ -715,7 +715,7 @@ use constant ABSTRACT_SCHEMA => {
   flagexclusions => {
     FIELDS => [
       type_id => {
-        TYPE       => 'INT2',
+        TYPE       => 'INT3',
         NOTNULL    => 1,
         REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
       },
index 772e96e854f5ccbd5ff60b49e68b6526990b2b34..6a5db1fd1bc958c5a6dfcac36f348b7ae36baf5a 100644 (file)
@@ -475,9 +475,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});
@@ -839,6 +838,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 $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) = (@_);