Index: package/hosting_package.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/hosting/package/hosting_package.install,v
retrieving revision 1.14
diff -u -r1.14 hosting_package.install
--- package/hosting_package.install	28 Sep 2009 16:24:07 -0000	1.14
+++ package/hosting_package.install	1 Oct 2009 07:29:05 -0000
@@ -296,3 +296,26 @@
 
   return $ret;
 }
+
+// Remove duplicate packages introduced by a double validation of platform in 0.4 alpha 1
+function hosting_package_update_11() {
+  $ret = array();
+
+  $duplicate = array();
+  $result = db_query("SELECT nid FROM {hosting_package} WHERE nid NOT IN (SELECT package_id FROM {hosting_package_instance})");
+  while ($res = db_fetch_array($result)) {
+    $duplicate[] = $res['nid'];
+  }
+
+  if (count($duplicate)) {
+    $tables = array('hosting_package', 'node', 'node_revisions');
+    $duplicates = implode(', ', $duplicate);
+    foreach ($tables as $table) {
+      $query = sprintf("DELETE FROM {%s} WHERE nid IN (%s)", $table, $duplicates);
+      $ret[] = update_sql($query);
+    }
+  }
+
+  return $ret;
+}
+
