Index: modules/project_issue/project_issue.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.install,v retrieving revision 1.1.2.2.2.1 diff -u -p -r1.1.2.2.2.1 project_issue.install --- modules/project_issue/project_issue.install 12 Nov 2006 09:22:15 -0000 1.1.2.2.2.1 +++ modules/project_issue/project_issue.install 1 Mar 2007 09:57:58 -0000 @@ -117,6 +117,7 @@ function project_issue_install() { file_size int default 0 NOT NULL, PRIMARY KEY (cid) );"); + db_query("CREATE SEQUENCE {project_comments}_cid_seq INCREMENT 1 START 1"); } if (!project_issue_db_table_exists('project_subscriptions')) { db_query("CREATE TABLE {project_subscriptions} ( @@ -187,6 +188,23 @@ function project_issue_update_1() { return $ret; } +/** + * Add missing sequence for project comments on pgsql. To avoid SQL + * errors when update.php runs (in case the update is run multiple + * times, or a site manually fixed this bug already, etc), we make + * sure this sequence doesn't already exist before we try to create it. + */ +function project_issue_update_2() { + $ret = array(); + switch ($GLOBALS['db_type']) { + case 'pgsql': + if (!db_num_rows(db_query("SELECT relname FROM pg_class WHERE relname = '{project_comments}_cid_seq' AND relkind='S'"))) { + $ret[] = update_sql("CREATE SEQUENCE {project_comments}_cid_seq INCREMENT 1 START 1"); + } + break; + } + return $ret; +} function project_issue_db_table_exists($table) { switch ($GLOBALS['db_type']) { Index: modules/project_issue/comment.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/comment.inc,v retrieving revision 1.70.4.6 diff -u -p -r1.70.4.6 comment.inc --- modules/project_issue/comment.inc 23 Jan 2007 23:51:17 -0000 1.70.4.6 +++ modules/project_issue/comment.inc 1 Mar 2007 09:57:59 -0000 @@ -198,7 +198,7 @@ function project_comment_save($edit) { global $user; if (empty($edit->cid)) { - $edit->cid = db_next_id('{project}_cid'); + $edit->cid = db_next_id('{project_comments}_cid'); if ($edit->file) { $directory = file_create_path(variable_get('project_directory_issues', 'issues')); $edit->file->filename = project_issue_munge_filename($edit->file->filename);