You are here

function privatemsg_update_6201 in Privatemsg 6.2

Change schema to allow other recipients than single users.

File

./privatemsg.install, line 566
Install file for privatemsg.module

Code

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

  // Make sure to not run this update twice.
  if (db_column_exists('pm_index', 'recipient')) {
    return $ret;
  }
  db_drop_index($ret, 'pm_index', 'list');
  db_drop_index($ret, 'pm_index', 'messages');
  db_drop_index($ret, 'pm_index', 'participants');
  db_change_field($ret, 'pm_index', 'uid', 'recipient', array(
    'description' => 'ID of the recipient object, typically user',
    'type' => 'int',
    'not null' => TRUE,
    'unsigned' => TRUE,
  ));
  db_add_field($ret, 'pm_index', 'type', array(
    'description' => 'Type of recipient object',
    'type' => 'varchar',
    'not null' => TRUE,
    'length' => '255',
    'default' => 'user',
  ), array(
    'indexes' => array(
      'list' => array(
        'recipient',
        'type',
        'deleted',
        'is_new',
      ),
      'messages' => array(
        'mid',
        'recipient',
        'type',
      ),
      'participants' => array(
        'thread_id',
        'recipient',
        'type',
        'deleted',
      ),
    ),
  ));
  return $ret;
}