Bug 346241: Make series.creator nullable in the DB and use NULL for series with creator 0 - Patch by R�mi Zara <remi_zara@mac.com> r=wicked a=myk

This commit is contained in:
lpsolit%gmail.com 2006-08-19 20:56:51 +00:00
Родитель 63efd6f02f
Коммит 3ded6a1544
4 изменённых файлов: 15 добавлений и 11 удалений

Просмотреть файл

@ -915,7 +915,7 @@ use constant ABSTRACT_SCHEMA => {
FIELDS => [
series_id => {TYPE => 'MEDIUMSERIAL', NOTNULL => 1,
PRIMARYKEY => 1},
creator => {TYPE => 'INT3', NOTNULL => 1},
creator => {TYPE => 'INT3'},
category => {TYPE => 'INT2', NOTNULL => 1},
subcategory => {TYPE => 'INT2', NOTNULL => 1},
name => {TYPE => 'varchar(64)', NOTNULL => 1},

Просмотреть файл

@ -277,6 +277,14 @@ sub update_table_definitions {
_remove_spaces_and_commas_from_flagtypes();
_setup_usebuggroups_backward_compatibility();
_remove_user_series_map();
# 2006-08-03 remi_zara@mac.com bug 346241, make series.creator nullable
# This must happen before calling _copy_old_charts_into_database().
if ($dbh->bz_column_info('series', 'creator')->{NOTNULL}) {
$dbh->bz_alter_column('series', 'creator', {TYPE => 'INT3'});
$dbh->do("UPDATE series SET creator = NULL WHERE creator = 0");
}
_copy_old_charts_into_database();
_add_user_group_map_grant_type();
@ -1877,9 +1885,8 @@ sub _copy_old_charts_into_database {
foreach my $field (@fields) {
# Create a Series for each field in this product.
# user ID = 0 is used.
my $series = new Bugzilla::Series(undef, $product, $all_name,
$field, 0, 1,
$field, undef, 1,
$queries{$field}, 1);
$series->writeToDatabase();
$seriesids{$field} = $series->{'series_id'};
@ -1890,7 +1897,7 @@ sub _copy_old_charts_into_database {
my @openedstatuses = ("UNCONFIRMED", "NEW", "ASSIGNED", "REOPENED");
my $query = join("&", map { "bug_status=$_" } @openedstatuses);
my $series = new Bugzilla::Series(undef, $product, $all_name,
$open_name, 0, 1,
$open_name, undef, 1,
$query_prod . $query, 1);
$series->writeToDatabase();
$seriesids{$open_name} = $series->{'series_id'};

Просмотреть файл

@ -36,8 +36,6 @@ use Bugzilla::Error;
use Bugzilla::Util;
use Bugzilla::User;
use constant PUBLIC_USER_ID => 0;
sub new {
my $invocant = shift;
my $class = ref($invocant) || $invocant;
@ -201,10 +199,9 @@ sub writeToDatabase {
# Insert the new series into the series table
$dbh->do("INSERT INTO series (creator, category, subcategory, " .
"name, frequency, query, is_public) VALUES " .
"($self->{'creator'}, " .
"$category_id, $subcategory_id, " .
$dbh->quote($self->{'name'}) . ", $self->{'frequency'}," .
$dbh->quote($self->{'query'}) . ", $self->{'public'})");
"(?, ?, ?, ?, ?, ?, ?)", undef,
$self->{'creator'}, $category_id, $subcategory_id, $self->{'name'},
$self->{'frequency'}, $self->{'query'}, $self->{'public'});
# Retrieve series_id
$self->{'series_id'} = $dbh->selectrow_array("SELECT MAX(series_id) " .

Просмотреть файл

@ -445,7 +445,7 @@ CrossCheck("profiles", "userid",
["logincookies", "userid"],
["namedqueries", "userid"],
["namedqueries_link_in_footer", "user_id"],
['series', 'creator', 'series_id', ['0']],
['series', 'creator', 'series_id'],
["watch", "watcher"],
["watch", "watched"],
['whine_events', 'owner_userid'],