You are here

function invite_update_201 in Invite 5.2

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

Revamped notification system.

File

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

Code

function invite_update_201() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("\n        CREATE TABLE {invite_notifications} (\n          uid int(10) NOT NULL default '0',\n          invitee int(10) NOT NULL default '0',\n          KEY (uid)\n        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      $ret[] = update_sql("\n        CREATE TABLE {invite_notifications} (\n          uid INTEGER NOT NULL DEFAULT 0,\n          invitee INTEGER NOT NULL DEFAULT 0\n        )");
      $ret[] = update_sql("CREATE INDEX {invite_notifications}_uid_idx ON {invite_notifications}(uid)");
      break;
  }

  // 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
  $ret[] = update_sql("ALTER TABLE {invite} DROP received");
  return $ret;
}