Skip to content

Commit 1351e2c

Browse files
authored
[harmony] Bug 1634711: Backport Bug 1526703 from 5.0.6 - Increase the size of the flagtype id column (#130)
1 parent e41274d commit 1351e2c

File tree

4 files changed

+54
-9
lines changed

4 files changed

+54
-9
lines changed

Bugzilla/DB/Schema.pm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ use constant ABSTRACT_SCHEMA => {
658658
FIELDS => [
659659
id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
660660
type_id => {
661-
TYPE => 'INT2',
661+
TYPE => 'INT3',
662662
NOTNULL => 1,
663663
REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
664664
},
@@ -694,7 +694,7 @@ use constant ABSTRACT_SCHEMA => {
694694
# "flagtypes" defines the types of flags that can be set.
695695
flagtypes => {
696696
FIELDS => [
697-
id => {TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
697+
id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
698698
name => {TYPE => 'varchar(50)', NOTNULL => 1},
699699
description => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
700700
cc_list => {TYPE => 'varchar(200)'},
@@ -721,7 +721,7 @@ use constant ABSTRACT_SCHEMA => {
721721
flaginclusions => {
722722
FIELDS => [
723723
type_id => {
724-
TYPE => 'INT2',
724+
TYPE => 'INT3',
725725
NOTNULL => 1,
726726
REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
727727
},
@@ -743,7 +743,7 @@ use constant ABSTRACT_SCHEMA => {
743743
flagexclusions => {
744744
FIELDS => [
745745
type_id => {
746-
TYPE => 'INT2',
746+
TYPE => 'INT3',
747747
NOTNULL => 1,
748748
REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
749749
},

Bugzilla/Install/DB.pm

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,8 @@ sub update_table_definitions {
483483
$dbh->bz_drop_column('profiles', 'refreshed_when');
484484
$dbh->bz_drop_column('groups', 'last_changed');
485485

486-
# 2006-08-06 LpSolit@gmail.com - Bug 347521
487-
$dbh->bz_alter_column('flagtypes', 'id',
488-
{TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1});
486+
# 2019-01-31 dylan@hardison.net - Bug TODO
487+
_update_flagtypes_id();
489488

490489
$dbh->bz_alter_column('keyworddefs', 'id',
491490
{TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1});
@@ -906,6 +905,30 @@ sub _update_product_name_definition {
906905
}
907906
}
908907

908+
sub _update_flagtypes_id {
909+
my $dbh = Bugzilla->dbh;
910+
my @fixes = (
911+
{table => 'flaginclusions', column => 'type_id'},
912+
{table => 'flagexclusions', column => 'type_id'},
913+
{table => 'flags', column => 'type_id'},
914+
);
915+
my $flagtypes_def = $dbh->bz_column_info('flagtypes', 'id');
916+
foreach my $fix (@fixes) {
917+
my $def = $dbh->bz_column_info($fix->{table}, $fix->{column});
918+
if ($def->{TYPE} eq 'INT2') {
919+
warn "Dropping foreign keys on $fix->{table}\n";
920+
$dbh->bz_drop_related_fks($fix->{table}, $fix->{column});
921+
$def->{TYPE} = 'INT3';
922+
$dbh->bz_alter_column($fix->{table}, $fix->{column}, $def);
923+
}
924+
}
925+
926+
if ($flagtypes_def->{TYPE} eq 'SMALLSERIAL') {
927+
$flagtypes_def->{TYPE} = 'MEDIUMSERIAL';
928+
$dbh->bz_alter_column('flagtypes', 'id', $flagtypes_def);
929+
}
930+
}
931+
909932
# A helper for the function below.
910933
sub _write_one_longdesc {
911934
my ($id, $who, $when, $buffer) = (@_);

extensions/FlagTypeComment/Extension.pm

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ sub db_schema_abstract_schema {
4242
$args->{'schema'}->{'flagtype_comments'} = {
4343
FIELDS => [
4444
type_id => {
45-
TYPE => 'INT2',
45+
TYPE => 'INT3',
4646
NOTNULL => 1,
4747
REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
4848
},
@@ -53,6 +53,19 @@ sub db_schema_abstract_schema {
5353
};
5454
}
5555

56+
sub install_update_db {
57+
my $dbh = Bugzilla->dbh;
58+
59+
# Bug 1634711 - justdave@bugzilla.org
60+
my $def = $dbh->bz_column_info('flagtype_comments', 'type_id');
61+
if ($def->{TYPE} eq 'INT2') {
62+
warn "Dropping foreign keys on flagtype_comments\n";
63+
$dbh->bz_drop_related_fks('flagtype_comments', 'type_id');
64+
$def->{TYPE} = 'INT3';
65+
$dbh->bz_alter_column('flagtype_comments', 'type_id', $def);
66+
}
67+
}
68+
5669
#############
5770
# Templates #
5871
#############

extensions/Review/Extension.pm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ sub db_schema_abstract_schema {
856856
flag_when => {TYPE => 'DATETIME', NOTNULL => 1,},
857857

858858
type_id => {
859-
TYPE => 'INT2',
859+
TYPE => 'INT3',
860860
NOTNULL => 1,
861861
REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'}
862862
},
@@ -954,6 +954,15 @@ sub install_update_db {
954954

955955
# Bug 1588221 - dkl@mozilla.com
956956
$dbh->bz_alter_column('flag_state_activity', 'attachment_id', {TYPE => 'INT5'});
957+
958+
# Bug 1634711 - justdave@bugzilla.org
959+
my $def = $dbh->bz_column_info('flag_state_activity', 'type_id');
960+
if ($def->{TYPE} eq 'INT2') {
961+
warn "Dropping foreign keys on flag_state_activity\n";
962+
$dbh->bz_drop_related_fks('flag_state_activity', 'type_id');
963+
$def->{TYPE} = 'INT3';
964+
$dbh->bz_alter_column('flag_state_activity', 'type_id', $def);
965+
}
957966
}
958967

959968
sub install_filesystem {

0 commit comments

Comments
 (0)