You are here

function acl_update_2 in ACL 5

Same name and namespace in other branches
  1. 6 acl.install \acl_update_2()
  2. 7 acl.install \acl_update_2()

Fixes primary keys

File

./acl.install, line 97

Code

function acl_update_2() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':

      // drop the previously created indexes (except for acl_user.uid)
      $ret[] = update_sql('ALTER TABLE {acl} DROP INDEX acl_id');
      $ret[] = update_sql('ALTER TABLE {acl_user} DROP INDEX acl_id');
      $ret[] = update_sql('ALTER TABLE {acl_node} DROP INDEX acl_id');
      $ret[] = update_sql('ALTER TABLE {acl_node} DROP INDEX nid');

      // create new indexes (as primary keys this time)
      $ret[] = update_sql('ALTER TABLE {acl} ADD PRIMARY KEY (acl_id)');
      $ret[] = update_sql('ALTER TABLE {acl_user} ADD PRIMARY KEY (acl_id, uid)');
      $ret[] = update_sql('ALTER TABLE {acl_node} ADD PRIMARY KEY (acl_id, nid)');
      break;
    case 'pgsql':
      $ret[] = update_sql('ALTER TABLE {acl} DROP PRIMARY KEY , ADD PRIMARY KEY (acl_id)');
      $ret[] = update_sql('ALTER TABLE {acl_user} DROP PRIMARY KEY , ADD PRIMARY KEY (acl_id, uid)');
      $ret[] = update_sql('ALTER TABLE {acl_node} DROP PRIMARY KEY , ADD PRIMARY KEY (acl_id, nid)');
      $ret[] = update_sql('CREATE INDEX {acl_user}_uid_index ON {acl_user} (uid)');
      break;
  }
  return $ret;
}