From: mkanat%bugzilla.org <> Date: Tue, 2 Jun 2009 00:10:04 +0000 (+0000) Subject: Bug 495783: Create the default Classification before setting up foreign keys, so... X-Git-Tag: bugzilla-3.5.1~211 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=34e54028237fed966388a7d3b4f7e7321a92a2e4;p=thirdparty%2Fbugzilla.git Bug 495783: Create the default Classification before setting up foreign keys, so that the products.classification_id -> classifications.id FK doesn't fail during upgrades that add the classification_id column. Patch by Max Kanat-Alexander r=LpSolit, a=mkanat --- diff --git a/Bugzilla/Install.pm b/Bugzilla/Install.pm index 65e19412cc..c469aa857c 100644 --- a/Bugzilla/Install.pm +++ b/Bugzilla/Install.pm @@ -217,15 +217,20 @@ sub update_system_groups { } -# This function should be called only after creating the admin user. -sub create_default_product { +sub create_default_classification { my $dbh = Bugzilla->dbh; + # Make the default Classification if it doesn't already exist. if (!$dbh->selectrow_array('SELECT 1 FROM classifications')) { - print get_text('install_default_classification', + print get_text('install_default_classification', { name => DEFAULT_CLASSIFICATION->{name} }) . "\n"; Bugzilla::Classification->create(DEFAULT_CLASSIFICATION); } +} + +# This function should be called only after creating the admin user. +sub create_default_product { + my $dbh = Bugzilla->dbh; # And same for the default product/component. if (!$dbh->selectrow_array('SELECT 1 FROM products')) { @@ -426,9 +431,14 @@ Params: none Returns: nothing. +=item C + +Creates the default "Unclassified" L +if it doesn't already exist + =item C -Description: Creates the default product and classification if +Description: Creates the default product and component if they don't exist. Params: none diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 0c91816553..53f800b82f 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -24,6 +24,7 @@ use strict; use Bugzilla::Constants; use Bugzilla::Hook; +use Bugzilla::Install (); use Bugzilla::Install::Util qw(indicate_progress install_string); use Bugzilla::Util; use Bugzilla::Series; @@ -578,6 +579,13 @@ sub update_table_definitions { Bugzilla::Hook::process('install-update_db'); + # We do this here because otherwise the foreign key from + # products.classification_id to classifications.id will fail + # (because products.classification_id defaults to "1", so on upgraded + # installations it's already been set before the first Classification + # exists). + Bugzilla::Install::create_default_classification(); + $dbh->bz_setup_foreign_keys(); } diff --git a/checksetup.pl b/checksetup.pl index 53a709ebf3..0f410ed7de 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -217,7 +217,7 @@ Bugzilla::Install::reset_password($switch{'reset-password'}) if $switch{'reset-password'}; ########################################################################### -# Create default Product and Classification +# Create default Product ########################################################################### Bugzilla::Install::create_default_product(); @@ -406,6 +406,10 @@ from one version of Bugzilla to another. The code for this is in L. +This includes creating the default Classification (using +L) and setting up all +the foreign keys for all tables, using L. + =item 14 Creates the system groups--the ones like C, C, and so on. @@ -426,7 +430,7 @@ the C<--make-admin> switch. =item 17 -Creates the default Classification, Product, and Component, using +Creates the default Product and Component, using L. =back