From: lpsolit%gmail.com <> Date: Tue, 8 Aug 2006 05:13:59 +0000 (+0000) Subject: Bug 347521: flagtypes.id should be an auto-increment field - Patch by Frédéric Buclin... X-Git-Tag: bugzilla-2.23.3~180 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c377e30d41de59b2c00beaea45710445e70f2c9;p=thirdparty%2Fbugzilla.git Bug 347521: flagtypes.id should be an auto-increment field - Patch by Frédéric Buclin r=bkor a=myk --- diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index 5e5b23bab8..e997e41873 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -397,7 +397,7 @@ use constant ABSTRACT_SCHEMA => { # "flagtypes" defines the types of flags that can be set. flagtypes => { FIELDS => [ - id => {TYPE => 'INT2', NOTNULL => 1, + id => {TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1}, name => {TYPE => 'varchar(50)', NOTNULL => 1}, description => {TYPE => 'TEXT'}, diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 5fe84a4f45..dfe7f957a7 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -464,6 +464,10 @@ sub update_table_definitions { $dbh->bz_drop_column('profiles', 'refreshed_when'); $dbh->bz_drop_column('groups', 'last_changed'); + # 2006-08-06 LpSolit@gmail.com - Bug 347521 + $dbh->bz_alter_column('flagtypes', 'id', + {TYPE => 'SMALLSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ diff --git a/editflagtypes.cgi b/editflagtypes.cgi index 3c71d5bdbe..622cfcb051 100755 --- a/editflagtypes.cgi +++ b/editflagtypes.cgi @@ -306,22 +306,22 @@ sub insert { 'components READ', 'flaginclusions WRITE', 'flagexclusions WRITE'); - # Determine the new flag type's unique identifier. - my $id = $dbh->selectrow_array('SELECT MAX(id) FROM flagtypes') + 1; - # Insert a record for the new flag type into the database. $dbh->do('INSERT INTO flagtypes - (id, name, description, cc_list, target_type, + (name, description, cc_list, target_type, sortkey, is_active, is_requestable, is_requesteeble, is_multiplicable, grant_group_id, request_group_id) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', - undef, ($id, $name, $description, $cc_list, $target_type, + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + undef, ($name, $description, $cc_list, $target_type, $cgi->param('sortkey'), $cgi->param('is_active'), $cgi->param('is_requestable'), $cgi->param('is_requesteeble'), $cgi->param('is_multiplicable'), scalar($cgi->param('grant_gid')), scalar($cgi->param('request_gid')))); + # Get the ID of the new flag type. + my $id = $dbh->bz_last_key('flagtypes', 'id'); + # Populate the list of inclusions/exclusions for this flag type. validateAndSubmit($id);