You are here

function og_update_14 in Organic groups 6

Same name and namespace in other branches
  1. 5.8 og.install \og_update_14()
  2. 5 og.install \og_update_14()
  3. 5.2 og.install \og_update_14()
  4. 5.3 og.install \og_update_14()
  5. 5.7 og.install \og_update_14()
  6. 6.2 og.install \og_update_14()

File

./og.install, line 175

Code

function og_update_14() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("CREATE TABLE {og_ancestry} (\n        nid int(11) NOT NULL,\n        group_nid int(11) NOT NULL,\n        is_public int(1) NULL,\n        KEY  (nid),\n        KEY  (group_nid)\n      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      db_query("CREATE TABLE {og_ancestry} (\n        nid int NOT NULL,\n        group_nid int NOT NULL,\n        is_public smallint NOT NULL\n      );");
      db_query("CREATE INDEX {og_ancestry}_nid_idx ON {og_ancestry} (nid);");
      db_query("CREATE INDEX {og_ancestry}_group_nid_idx ON {og_ancestry} (group_nid);");
      break;
  }
  og_migrate_type_basic_14();

  // populate og_ancestry.
  $result = db_query_temporary("SELECT na.nid, na.gid, IF(MIN(na.realm) = 'og_all', 1, 0) AS is_public \n     FROM {node_access} na INNER JOIN {node} n ON na.nid=n.nid \n     WHERE realm IN ('og_all', 'og_subscriber') AND n.type NOT IN ('%s') GROUP BY na.nid, na.gid ORDER BY nid ASC", implode(', ', variable_get('og_node_types', array(
    'og',
  ))), 'og_migrate');
  $sql = "INSERT INTO {og_ancestry} (nid, group_nid, is_public) SELECT nid, gid, is_public FROM {og_migrate}";
  db_query($sql);

  // rebuild takes care of writing new access records
  // too bad this part can't be performed over multiple updates
  node_access_rebuild();
  return array();
}