Index: project_issue.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.install,v
retrieving revision 1.10
diff -u -F^f -b -r1.10 project_issue.install
--- project_issue.install	13 Jul 2007 03:29:27 -0000	1.10
+++ project_issue.install	9 Aug 2007 19:54:55 -0000
@@ -147,6 +147,12 @@ function project_issue_install() {
     project_issue_init_state(8, 'patch (code needs review)', -8, 0, 0);
     project_issue_init_state(13, 'patch (code needs work)', -6, 0, 0);
     project_issue_init_state(14, 'patch (ready to commit)', -2, 0, 0);
+
+    // Since we're hacking in auto-increment values here,
+    // update the sequence value for Postgres -- ugly but necessary for now.
+    if ($GLOBALS['db_type'] == 'pgsql') {
+      db_query("SELECT setval('project_issue_state_sid_seq', 14)");
+    }
   }
 
   db_query("UPDATE {system} SET weight = 2 WHERE name = 'project_issue'");
@@ -242,3 +248,17 @@ function project_issue_update_502() {
   }
   return $ret;
 }
+
+/**
+ * Fix custom issue states. The sid needs to be set properly for the sequence.
+ */
+function project_issue_update_503() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'pgsql':
+      $last_sid = db_result(db_query('SELECT MAX(sid) FROM project_issue_state'));
+      db_query("SELECT setval('project_issue_state_sid_seq', %d)", $last_sid);
+      break;
+  }
+  return $ret;
+}
