diff -urp old/og_subgroups/og_subgroups.install new/og_subgroups/og_subgroups.install
--- old/og_subgroups/og_subgroups.install	2008-06-01 17:15:46.000000000 +0300
+++ new/og_subgroups/og_subgroups.install	2008-06-05 01:33:14.781250000 +0300
@@ -39,3 +39,57 @@ function og_subgroups_uninstall() {
     variable_del($variable);
   }
 }
+
+/**
+ * Helper function migrate users with og_subgroups 5.x-3 to 5.x.4.
+*/
+function og_subgroups_migrate() {
+  // Get all nodes from og_ancestry that nid and group_nid are both group nodes. 
+  $all_groups = db_query("SELECT oga.nid AS gid, oga.group_nid AS parent FROM {og_ancestry} oga INNER JOIN {og} og ON og.nid = oga.nid");
+  $migrate = FALSE;
+  while ($group = db_fetch_object($all_groups)) {
+    $migrate = TRUE;
+    db_query('INSERT INTO {og_subgroups} (gid, parent) VALUES (%d, %d)', $group->gid, $group->parent);
+  }
+  if ($migrate) {
+    $ret = array(
+      'query' => t('Groups from versions prior to 5.x-4 were migrated.'),
+      'success' => TRUE,
+    );  
+    return $ret;
+  }
+}
+
+/**
+ * 
+ */
+function og_subgroups_update_1() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+      db_query("CREATE TABLE {og_subgroups} (
+        gid int(11) NOT NULL,
+        parent int(11) NOT NULL,
+        PRIMARY KEY (gid, parent)
+      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
+    break;
+    case 'pgsql':
+      db_query("
+      CREATE TABLE {og_ancestry} (
+       gid int NOT NULL,
+       parent int NOT NULL,
+       PRIMARY KEY (gid, parent)
+      );");
+      db_query("CREATE INDEX {og_subgroups}_gid_idx ON {og_subgroups} (gid);");
+      db_query("CREATE INDEX {og_subgroups}_parent_idx ON {og_subgroups} (parent);");
+      break;
+  }  
+  $ret[] = array(
+    'query' => t('{og_subgroups} table was installed.'),
+    'success' => TRUE,
+  );  
+  $ret[] = og_subgroups_migrate();
+  return $ret;  
+}
+
