You are here

function fivestar_comment_update_6100 in Fivestar 6.2

Same name and namespace in other branches
  1. 6 fivestar_comment.install \fivestar_comment_update_6100()

Add vote_id column to the fivestar_comment table. This update will only be run when upgrading to fivestar schema 6103.

1 call to fivestar_comment_update_6100()
fivestar_update_6103 in ./fivestar.install
Move comment support to a separate module.

File

./fivestar_comment.install, line 37
Installation file for Fivestar Comment module.

Code

function fivestar_comment_update_6100() {
  $ret = array();

  // This update will already be run as fivestar_comment_update_5100 on Drupal 5.
  if (FIVESTAR_VERSION >= 6100) {
    db_add_field($ret, 'fivestar_comment', 'vote_id', array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'default' => 0,
    ));
    db_add_index($ret, 'fivestar_comment', 'vote_id', array(
      'vote_id',
    ));
    $comments = db_query('SELECT fc.cid, fc.value, v.vote_id FROM {fivestar_comment} fc INNER JOIN {comments} c ON fc.cid = c.cid INNER JOIN {votingapi_vote} v ON fc.value = v.value AND c.nid = v.content_id AND c.uid = v.uid WHERE v.tag = "vote" AND v.value_type = "percent" AND v.content_type = "node"');
    while ($comment = db_fetch_object($comments)) {
      db_query('UPDATE {fivestar_comment} SET vote_id = %d WHERE cid = %d', $comment->vote_id, $comment->cid);
    }
  }
  return $ret;
}