Index: project_issue.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.install,v
retrieving revision 1.14
diff -u -F^f -b -r1.14 project_issue.install
--- project_issue.install	15 Aug 2007 19:40:58 -0000	1.14
+++ project_issue.install	15 Aug 2007 20:13:10 -0000
@@ -160,6 +160,8 @@ function project_issue_install() {
     }
   }
 
+  project_issue_add_new_projects();
+
   db_query("UPDATE {system} SET weight = 2 WHERE name = 'project_issue'");
 }
 
@@ -200,6 +202,10 @@ function project_issue_uninstall() {
   }
 }
 
+function project_issue_enable() {
+  project_issue_add_new_projects();
+}
+
 /**
  * Initialize a given issue state in the database.
  */
@@ -208,6 +214,18 @@ function project_issue_init_state($sid, 
 }
 
 /**
+ * Check for existing project nodes that do not have an entry in the
+ * {project_issue_projects} table, and add them.
+ *
+ */
+function project_issue_add_new_projects() {
+  $projects = db_query("SELECT n.nid, pi.nid AS issue_nid FROM {node} n LEFT JOIN project_issue_projects pi ON n.nid = pi.nid WHERE n.type = 'project_project' AND pi.nid IS NULL");
+  while ($project = db_fetch_object($projects)) {
+    db_query('INSERT INTO {project_issue_projects} (nid) VALUES (%d)', $project->nid);
+  }
+}
+
+/**
  * Repairs DB from issues that were automatically closed and lost
  * their version info.  See http://drupal.org/node/84555
  */
