Skip to content
Closed
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
10 changes: 5 additions & 5 deletions Bugzilla/DB/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ use constant ABSTRACT_SCHEMA => {
},
version => {TYPE => 'varchar(64)', NOTNULL => 1},
component_id => {
TYPE => 'INT2',
TYPE => 'INT3',
NOTNULL => 1,
REFERENCES => {TABLE => 'components', COLUMN => 'id'}
},
Expand Down Expand Up @@ -730,7 +730,7 @@ use constant ABSTRACT_SCHEMA => {
REFERENCES => {TABLE => 'products', COLUMN => 'id', DELETE => 'CASCADE'}
},
component_id => {
TYPE => 'INT2',
TYPE => 'INT3',
REFERENCES => {TABLE => 'components', COLUMN => 'id', DELETE => 'CASCADE'}
},
],
Expand All @@ -752,7 +752,7 @@ use constant ABSTRACT_SCHEMA => {
REFERENCES => {TABLE => 'products', COLUMN => 'id', DELETE => 'CASCADE'}
},
component_id => {
TYPE => 'INT2',
TYPE => 'INT3',
REFERENCES => {TABLE => 'components', COLUMN => 'id', DELETE => 'CASCADE'}
},
],
Expand Down Expand Up @@ -1162,7 +1162,7 @@ use constant ABSTRACT_SCHEMA => {
REFERENCES => {TABLE => 'profiles', COLUMN => 'userid', DELETE => 'CASCADE'}
},
component_id => {
TYPE => 'INT2',
TYPE => 'INT3',
NOTNULL => 1,
REFERENCES => {TABLE => 'components', COLUMN => 'id', DELETE => 'CASCADE'}
},
Expand Down Expand Up @@ -1447,7 +1447,7 @@ use constant ABSTRACT_SCHEMA => {

components => {
FIELDS => [
id => {TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1},
name => {TYPE => 'varchar(64)', NOTNULL => 1},
product_id => {
TYPE => 'INT2',
Expand Down
12 changes: 12 additions & 0 deletions Bugzilla/Install/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,15 @@ sub update_table_definitions {
{table => 'user_request_log', column => 'attach_id', definition => {TYPE => 'INT5', NOTNULL => 0}},
]);

# Bug 903895 - sgreen@redhat.com
$dbh->bz_fk_safe_alter_columns([
{table => 'flaginclusions', column => 'component_id', definition => {TYPE => 'INT3'}},
{table => 'flagexclusions', column => 'component_id', definition => {TYPE => 'INT3'}},
{table => 'bugs', column => 'component_id', definition => {TYPE => 'INT3', NOTNULL => 1}},
{table => 'component_cc', column => 'component_id', definition => {TYPE => 'INT3', NOTNULL => 1}},
{table => 'components', column => 'id', definition => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1}},
]);

_populate_attachment_storage_class();


Expand Down Expand Up @@ -1592,6 +1601,9 @@ sub _use_ids_for_products_and_components {

print "Updating the database to use component IDs.\n";

# NOTE: These columns are now MEDIUMSERIAL/INT3 in the current schema, but
# historically were originally created as SMALLSERIAL/INT2. The upgrade steps
# are done in order; they will be converted to the correct current type later.
$dbh->bz_add_column("components", "id",
{TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1});
$dbh->bz_add_column("bugs", "component_id", {TYPE => 'INT2', NOTNULL => 1}, 0);
Expand Down
38 changes: 36 additions & 2 deletions extensions/BugmailFilter/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ sub reorg_move_component {

sub db_schema_abstract_schema {
my ($self, $args) = @_;
my $component_id_type = _component_id_type_from_schema($args->{schema});

$args->{schema}->{bugmail_filters} = {
FIELDS => [
id => {TYPE => 'INTSERIAL', NOTNULL => 1, PRIMARYKEY => 1,},
Expand All @@ -441,7 +443,7 @@ sub db_schema_abstract_schema {
REFERENCES => {TABLE => 'products', COLUMN => 'id', DELETE => 'CASCADE'},
},
component_id => {
TYPE => 'INT2',
TYPE => $component_id_type,
NOTNULL => 0,
REFERENCES => {TABLE => 'components', COLUMN => 'id', DELETE => 'CASCADE'},
},
Expand All @@ -467,8 +469,40 @@ sub db_schema_abstract_schema {
}

sub install_update_db {
Bugzilla->dbh->bz_add_column('bugmail_filters', 'changer_id',
my $dbh = Bugzilla->dbh;
$dbh->bz_add_column('bugmail_filters', 'changer_id',
{TYPE => 'INT3', NOTNULL => 0,});

my $component_id_type = _component_id_type_from_db($dbh);

my @fixes = (
{table => 'bugmail_filters', column => 'product_id', definition => {TYPE => 'INT2', NOTNULL => 0}},
{table => 'bugmail_filters', column => 'component_id', definition => {TYPE => $component_id_type, NOTNULL => 0}},
);

$dbh->bz_fk_safe_alter_columns(\@fixes);
}

sub _component_id_type_from_schema {
my ($schema) = @_;

my $component_id_type = 'INT2';
my $len = scalar @{$schema->{components}->{FIELDS}};
for (my $i = 0; $i < $len - 1; $i += 2) {
next if $schema->{components}->{FIELDS}->[$i] ne 'id';
$component_id_type = 'INT3'
if $schema->{components}->{FIELDS}->[$i + 1]->{TYPE} eq 'MEDIUMSERIAL';
last;
}

return $component_id_type;
}

sub _component_id_type_from_db {
my ($dbh) = @_;

my $component_id = $dbh->bz_column_info('components', 'id');
return $component_id->{TYPE} eq 'MEDIUMSERIAL' ? 'INT3' : 'INT2';
}

sub db_sanitize {
Expand Down
5 changes: 5 additions & 0 deletions extensions/ComponentWatching/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ sub install_update_db {
);
$dbh->bz_add_column('component_watch', 'component_prefix',
{TYPE => 'VARCHAR(64)', NOTNULL => 0,});

# Bug 2052640 - justdave@bugzilla.org
$dbh->bz_fk_safe_alter_columns([
{table => 'component_watch', column => 'component_id', definition => {TYPE => 'INT3', NOTNULL => 0}},
]);
}

#
Expand Down
8 changes: 7 additions & 1 deletion extensions/Review/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ sub db_schema_abstract_schema {
},
display_name => {TYPE => 'VARCHAR(64)',},
component_id => {
TYPE => 'INT2',
TYPE => 'INT3',
NOTNULL => 1,
REFERENCES => {TABLE => 'components', COLUMN => 'id', DELETE => 'CASCADE',}
},
Expand Down Expand Up @@ -963,6 +963,12 @@ sub install_update_db {
$def->{TYPE} = 'INT3';
$dbh->bz_alter_column('flag_state_activity', 'type_id', $def);
}

# Bug 2052640 - justdave@bugzilla.org
$dbh->bz_fk_safe_alter_columns([
{table => 'component_reviewers', column => 'component_id', definition => {TYPE => 'INT3', NOTNULL => 1}},
]);

}

sub install_filesystem {
Expand Down
7 changes: 6 additions & 1 deletion extensions/TrackingFlags/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ sub db_schema_abstract_schema {
REFERENCES => {TABLE => 'products', COLUMN => 'id', DELETE => 'CASCADE',},
},
component_id => {
TYPE => 'INT2',
TYPE => 'INT3',
NOTNULL => 0,
REFERENCES => {TABLE => 'components', COLUMN => 'id', DELETE => 'CASCADE',},
},
Expand Down Expand Up @@ -289,6 +289,11 @@ sub install_update_db {
$dbh->bz_add_column('tracking_flags_values', 'comment',
{TYPE => 'TEXT', NOTNULL => 0,},
);

# Bug 2052640 - justdave@bugzilla.org
$dbh->bz_fk_safe_alter_columns([
{table => 'tracking_flags_visibility', column => 'component_id', definition => {TYPE => 'INT3', NOTNULL => 0}},
]);
}

sub install_filesystem {
Expand Down
8 changes: 7 additions & 1 deletion extensions/Webhooks/Extension.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ sub db_schema_abstract_schema {
REFERENCES => {TABLE => 'products', COLUMN => 'id', DELETE => 'CASCADE',}
},
component_id => {
TYPE => 'INT2',
TYPE => 'INT3',
NOTNULL => 0,
REFERENCES => {TABLE => 'components', COLUMN => 'id', DELETE => 'CASCADE',}
}
Expand All @@ -65,6 +65,12 @@ sub db_sanitize {
$dbh->do("DELETE FROM webhooks");
}

sub install_update_db {
Bugzilla->dbh->bz_fk_safe_alter_columns([
{table => 'webhooks', column => 'component_id', definition => {TYPE => 'INT3', NOTNULL => 0}},
]);
}

#
# preferences
#
Expand Down
Loading