You are here

function context_ui_update_6002 in Context 6

File

context_ui/context_ui.install, line 218

Code

function context_ui_update_6002() {
  $ret = array();
  $result = db_query("SELECT cid FROM {context_ui} WHERE system = 1");
  $cids = array();
  while ($row = db_fetch_object($result)) {
    $cids[] = $row->cid;
  }
  $cids = implode(',', $cids);
  if ($cids != '') {
    $ret[] = update_sql("DELETE FROM {context_ui} WHERE cid IN ({$cids})");
    $ret[] = update_sql("DELETE FROM {context_ui_setter} WHERE cid IN ({$cids})");
    $ret[] = update_sql("DELETE FROM {context_ui_getter} WHERE cid IN ({$cids})");
    $ret[] = update_sql("DELETE FROM {context_ui_block} WHERE cid IN ({$cids})");
  }
  db_drop_field($ret, 'context_ui', 'system');
  db_drop_field($ret, 'context_ui', 'status');
  $schema = context_ui_schema();

  // Update status field
  db_drop_unique_key($ret, 'context_ui', 'key1');
  db_add_unique_key($ret, 'context_ui', 'key1', $schema['context_ui']['unique keys']['key1']);
  return $ret;
}