You are here

function invite_update_201 in Invite 6.2

Same name and namespace in other branches
  1. 5.2 invite.install \invite_update_201()
  2. 7.2 invite.install \invite_update_201()

Revamped notification system.

File

./invite.install, line 350
Installation file for invite module.

Code

function invite_update_201() {
  $ret = array();
  db_create_table($ret, 'invite_notifications', array(
    'description' => 'Stores notifications of inviters.',
    'fields' => array(
      'uid' => array(
        'description' => 'Stores the user id to be notified (inviter).',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'invitee' => array(
        'description' => 'Stores the user id of the invitee.',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'indexes' => array(
      'uid' => array(
        'uid',
      ),
    ),
  ));

  // Convert old data
  $ret[] = update_sql("INSERT INTO {invite_notifications} (uid, invitee) SELECT uid, invitee FROM {invite} WHERE joined <> 0 AND received = 0");

  // Drop old column
  db_drop_field($ret, 'invite', 'received');
  return $ret;
}