summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-07-10 06:23:26 +0200
committerByron Jones <glob@mozilla.com>2015-07-10 06:23:26 +0200
commit65e910a8df06895d07b595c842c013f7f8c98dff (patch)
tree454afe8c86ee7d145d589dd3a3f782adfd82c896 /extensions
parent51689c00f62c5826544842ada75b1122eed3b06f (diff)
downloadbugzilla-65e910a8df06895d07b595c842c013f7f8c98dff.tar.gz
bugzilla-65e910a8df06895d07b595c842c013f7f8c98dff.tar.xz
Bug 1182375: unable to create a database from scratch: Unknown column 'secure_mail' in 'field list'
Diffstat (limited to 'extensions')
-rw-r--r--extensions/BMO/Extension.pm34
1 files changed, 19 insertions, 15 deletions
diff --git a/extensions/BMO/Extension.pm b/extensions/BMO/Extension.pm
index f90f08318..5515f56db 100644
--- a/extensions/BMO/Extension.pm
+++ b/extensions/BMO/Extension.pm
@@ -1126,22 +1126,26 @@ sub install_update_db {
},
}
);
- # Migrate values in Data.pm
- # 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) {
- print "Security group $group_name not found. Using core-security instead.\n";
- next;
+
+ # 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 values in Data.pm
+ # 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);
}
- $dbh->do("UPDATE products SET security_group_id = ? WHERE name = ?",
- undef, $group->id, $prod_name);
}
}
}