diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index bc14d18f4b..4268796c42 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -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'} }, @@ -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'} }, @@ -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'} }, ], @@ -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'} }, @@ -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'} }, ], @@ -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'} }, @@ -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', diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index b2155d057e..32be6b9194 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -484,8 +484,15 @@ sub update_table_definitions { $dbh->bz_drop_column('groups', 'last_changed'); # 2006-08-06 LpSolit@gmail.com - Bug 347521 + $dbh->bz_drop_related_fks('flagtypes', 'id'); $dbh->bz_alter_column('flagtypes', 'id', - {TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); + {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); + $dbh->bz_alter_column('flags', 'type_id', + {TYPE => 'INT3', NOTNULL => 1}); + $dbh->bz_alter_column('flaginclusions', 'type_id', + {TYPE => 'INT3', NOTNULL => 1}); + $dbh->bz_alter_column('flagexclusions', 'type_id', + {TYPE => 'INT3', NOTNULL => 1}); $dbh->bz_alter_column('keyworddefs', 'id', {TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); @@ -809,13 +816,18 @@ sub update_table_definitions { $dbh->bz_add_column('profiles', 'bounce_count', {TYPE => 'INT1', NOTNULL => 1, DEFAULT => 0}); # Bug 1588221 - dkl@mozilla.com + # TODO: skip droping fks if attach_id did not change types. + $dbh->bz_drop_fk('bugs_activity', 'attach_id'); $dbh->bz_alter_column('bugs_activity', 'attach_id', {TYPE => 'INT5'}); + $dbh->bz_drop_fk('flags', 'attach_id'); + $dbh->bz_alter_column('flags', 'attach_id', {TYPE => 'INT5'}); + $dbh->bz_drop_fk('user_request_log', 'attach_id'); + $dbh->bz_alter_column('user_request_log', 'attach_id', {TYPE => 'INT5', NOTNULL => 0}); + $dbh->bz_drop_fk('attach_data', 'id'); $dbh->bz_alter_column('attachments', 'attach_id', {TYPE => 'BIGSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); $dbh->bz_alter_column('attach_data', 'id', {TYPE => 'INT5', NOTNULL => 1, PRIMARYKEY => 1}); - $dbh->bz_alter_column('flags', 'attach_id', {TYPE => 'INT5'}); - $dbh->bz_alter_column('user_request_log', 'attach_id', {TYPE => 'INT5', NOTNULL => 0}); _populate_attachment_storage_class(); @@ -4227,8 +4239,6 @@ sub _migrate_group_owners { my $dbh = Bugzilla->dbh; return if $dbh->bz_column_info('groups', 'owner_user_id'); $dbh->bz_add_column('groups', 'owner_user_id', {TYPE => 'INT3'}); - my $nobody = Bugzilla::User->check('nobody@mozilla.org'); - $dbh->do('UPDATE groups SET owner_user_id = ?', undef, $nobody->id); } sub _migrate_nicknames { diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm index c46438f99d..d343ecaf9e 100644 --- a/extensions/BMO/Extension.pm +++ b/extensions/BMO/Extension.pm @@ -1473,88 +1473,6 @@ sub install_update_db { REFERENCES => {TABLE => 'groups', COLUMN => 'id', DELETE => 'SET NULL',}, } ); - - # if there are no groups, then we're creating a database from scratch - # and there's nothing to migrate - my ($group_count) = $dbh->selectrow_array("SELECT COUNT(*) FROM groups"); - if ($group_count) { - - # Migrate old product_sec_group mappings from the time this change was made - my %product_sec_groups = ( - "addons.mozilla.org" => 'client-services-security', - "Air Mozilla" => 'mozilla-employee-confidential', - "Android Background Services" => 'cloud-services-security', - "Audio/Visual Infrastructure" => 'mozilla-employee-confidential', - "AUS" => 'client-services-security', - "Bugzilla" => 'bugzilla-security', - "bugzilla.mozilla.org" => 'bugzilla-security', - "Cloud Services" => 'cloud-services-security', - "Community Tools" => 'websites-security', - "Data & BI Services Team" => 'metrics-private', - "Developer Documentation" => 'websites-security', - "Developer Ecosystem" => 'client-services-security', - "Finance" => 'finance', - "Firefox Friends" => 'mozilla-employee-confidential', - "Firefox Health Report" => 'cloud-services-security', - "Infrastructure & Operations" => 'mozilla-employee-confidential', - "Input" => 'websites-security', - "Intellego" => 'intellego-team', - "Internet Public Policy" => 'mozilla-employee-confidential', - "L20n" => 'l20n-security', - "Legal" => 'legal', - "Marketing" => 'marketing-private', - "Mozilla Communities" => 'mozilla-communities-security', - "Mozilla Corporation" => 'mozilla-employee-confidential', - "Mozilla Developer Network" => 'websites-security', - "Mozilla Foundation" => 'mozilla-employee-confidential', - "Mozilla Foundation Operations" => 'mozilla-foundation-operations', - "Mozilla Grants" => 'grants', - "mozillaignite" => 'websites-security', - "Mozilla Messaging" => 'mozilla-messaging-confidential', - "Mozilla Metrics" => 'metrics-private', - "mozilla.org" => 'mozilla-employee-confidential', - "Mozilla PR" => 'pr-private', - "Mozilla QA" => 'mozilla-employee-confidential', - "Mozilla Reps" => 'mozilla-reps', - "Popcorn" => 'websites-security', - "Privacy" => 'privacy', - "quality.mozilla.org" => 'websites-security', - "Recruiting" => 'hr', - "Release Engineering" => 'mozilla-employee-confidential', - "Snippets" => 'websites-security', - "Socorro" => 'client-services-security', - "support.mozillamessaging.com" => 'websites-security', - "support.mozilla.org" => 'websites-security', - "Talkback" => 'talkback-private', - "Tamarin" => 'tamarin-security', - "Taskcluster" => 'taskcluster-security', - "Testopia" => 'bugzilla-security', - "Tree Management" => 'mozilla-employee-confidential', - "Web Apps" => 'client-services-security', - "Webmaker" => 'websites-security', - "Websites" => 'websites-security', - "Webtools" => 'webtools-security', - "www.mozilla.org" => 'websites-security', - ); - - # 1. Set all to core-security by default - my $core_sec_group = Bugzilla::Group->new({name => 'core-security'}); - $dbh->do("UPDATE products SET security_group_id = ?", - undef, $core_sec_group->id); - - # 2. Update the ones that have explicit security groups - foreach my $prod_name (keys %product_sec_groups) { - my $group_name = $product_sec_groups{$prod_name}; - next if $group_name eq 'core-security'; # already done - my $group = Bugzilla::Group->new({name => $group_name, cache => 1}); - if (!$group) { - warn "Security group $group_name not found. Using core-security instead.\n"; - next; - } - $dbh->do("UPDATE products SET security_group_id = ? WHERE name = ?", - undef, $group->id, $prod_name); - } - } } # Add pronouns for Firefox/Thunderbird Status/Tracking Flags such as diff --git a/extensions/BugmailFilter/Extension.pm b/extensions/BugmailFilter/Extension.pm index a05953336a..b0f7b1c981 100644 --- a/extensions/BugmailFilter/Extension.pm +++ b/extensions/BugmailFilter/Extension.pm @@ -441,7 +441,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'}, }, diff --git a/extensions/FlagTypeComment/Extension.pm b/extensions/FlagTypeComment/Extension.pm index e5892fcbe9..c065001af1 100644 --- a/extensions/FlagTypeComment/Extension.pm +++ b/extensions/FlagTypeComment/Extension.pm @@ -42,7 +42,7 @@ sub db_schema_abstract_schema { $args->{'schema'}->{'flagtype_comments'} = { FIELDS => [ type_id => { - TYPE => 'SMALLINT(6)', + TYPE => 'INT3', NOTNULL => 1, REFERENCES => {TABLE => 'flagtypes', COLUMN => 'id', DELETE => 'CASCADE'} }, diff --git a/extensions/Review/Extension.pm b/extensions/Review/Extension.pm index fa4900ff2a..a338b76c84 100644 --- a/extensions/Review/Extension.pm +++ b/extensions/Review/Extension.pm @@ -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',} }, @@ -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'} }, diff --git a/extensions/TrackingFlags/Extension.pm b/extensions/TrackingFlags/Extension.pm index 297f986fd4..19f0d37afe 100644 --- a/extensions/TrackingFlags/Extension.pm +++ b/extensions/TrackingFlags/Extension.pm @@ -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',}, }, diff --git a/extensions/Webhooks/Extension.pm b/extensions/Webhooks/Extension.pm index 1a02ea9bfe..151a3f0a93 100644 --- a/extensions/Webhooks/Extension.pm +++ b/extensions/Webhooks/Extension.pm @@ -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',} }