You are here

function userpoints_update_7001 in User Points 7

Same name and namespace in other branches
  1. 7.2 userpoints.install \userpoints_update_7001()

Add a few indexes to speed up contrib modules that query the `points` columns.

Add index on points columns in userpoints and userpoints_txn, as well as on the two uid columns in userpoints_txn. No need to add a uid index in userpoints, as the compound uid_tid index is used instead when needed.

Since these indexes are added in a 6.x update as well, they need to be conditional in this update. Otherwise users get errors, which is bad.

File

./userpoints.install, line 239
Install time hook userpoints module.

Code

function userpoints_update_7001() {
  if (!db_index_exists('userpoints', 'points')) {
    db_add_index('userpoints', 'points', array(
      'points',
    ));
  }
  if (!db_index_exists('userpoints_txn', 'uid')) {
    db_add_index('userpoints_txn', 'uid', array(
      'uid',
    ));
  }
  if (!db_index_exists('userpoints_txn', 'approver_uid')) {
    db_add_index('userpoints_txn', 'approver_uid', array(
      'approver_uid',
    ));
  }
  if (!db_index_exists('userpoints_txn', 'points')) {
    db_add_index('userpoints_txn', 'points', array(
      'points',
    ));
  }
}