<?php
/**
 * @file
 * User relationship blocks installation
 */

/**
 * Schema
 */
function user_relationship_blocks_schema() {
  $schema['user_relationship_blocks'] = array(
    'fields' => array(
      'bid'         => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
      'size'        => array('type' => 'int', 'unsigned' => TRUE, 'default' => 10),
      'sort'        => array('type' => 'varchar', 'length' => 255, 'default' => 'newest'),
    ),
    'primary key' => array('bid'),
  );

  return $schema;
}

/**
 * Implements hook_update_N().
 * Update 6000 creates db tables after upgrade from D5.
 */
function user_relationship_blocks_update_6000() {
  //do not execute if table already exists, to catch normal D6 updates.
  if (db_table_exists('user_relationship_blocks')) {
    return array();
  }
  user_relationship_blocks_install();
  return array();
}

/**
 * Implements hook_update_N().
 * Update 6100 updates block caching flags #458520.
 */
function user_relationship_blocks_update_6100() {
  $ret = array();
  $ret[] = update_sql("UPDATE {blocks} SET cache = -1 WHERE module = 'user_relationship_blocks' AND delta IN ('actions', 'pending', 'user-all', 'my-all')");
  return $ret;
}

/**
 * Drop unnecessary get_account column.
 */
function user_relationship_blocks_update_7000() {
  db_drop_field('user_relationship_blocks', 'get_account');
}

