]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 347521: flagtypes.id should be an auto-increment field - Patch by Frédéric Buclin...
authorlpsolit%gmail.com <>
Tue, 8 Aug 2006 05:13:59 +0000 (05:13 +0000)
committerlpsolit%gmail.com <>
Tue, 8 Aug 2006 05:13:59 +0000 (05:13 +0000)
Bugzilla/DB/Schema.pm
Bugzilla/Install/DB.pm
editflagtypes.cgi

index 5e5b23bab81124300bf2cd1cb1830cd9f114563b..e997e41873dbe7f6fafd84ba7f2591799890838b 100644 (file)
@@ -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'},
index 5fe84a4f457779c0e73ae3228647bf0e67dbab03..dfe7f957a7ff62a8fb59a4d25cca5511653f647f 100644 (file)
@@ -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 #
     ################################################################
index 3c71d5bdbebf3f150a67143aa19989a7133c8821..622cfcb05123688e3fed7d47e95ef4d0dfc4cc5f 100755 (executable)
@@ -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);