Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[harmony] Bug 1634711: Backport Bug 1526703 from 5.0.6 - Increase the size of the flagtype id column #130

Merged
merged 7 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Bugzilla/DB/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
},
Expand Down Expand Up @@ -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)'},
Expand All @@ -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'}
},
Expand All @@ -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'}
},
Expand Down
29 changes: 26 additions & 3 deletions Bugzilla/Install/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] - Bug 347521
$dbh->bz_alter_column('flagtypes', 'id',
{TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1});
# 2019-01-31 [email protected] - Bug TODO
_update_flagtypes_id();

$dbh->bz_alter_column('keyworddefs', 'id',
{TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1});
Expand Down Expand Up @@ -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) = (@_);
Expand Down
15 changes: 14 additions & 1 deletion extensions/FlagTypeComment/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
},
Expand All @@ -53,6 +53,19 @@ sub db_schema_abstract_schema {
};
}

sub install_update_db {
my $dbh = Bugzilla->dbh;

# Bug 1634711 - [email protected]
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 #
#############
Expand Down
11 changes: 10 additions & 1 deletion extensions/Review/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
},
Expand Down Expand Up @@ -954,6 +954,15 @@ sub install_update_db {

# Bug 1588221 - [email protected]
$dbh->bz_alter_column('flag_state_activity', 'attachment_id', {TYPE => 'INT5'});

# Bug 1634711 - [email protected]
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 {
Expand Down
Loading