You are here

function privatemsg_update_4 in Privatemsg 5.3

Same name and namespace in other branches
  1. 5 privatemsg.install \privatemsg_update_4()

File

./privatemsg.install, line 223

Code

function privatemsg_update_4() {
  $ret = array();
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {privatemsg} ADD type varchar(255) NOT NULL default '', ADD KEY (type)");
      $ret[] = update_sql("ALTER TABLE {privatemsg} CHANGE subject subject varchar(255) NOT NULL default ''");
      if (!db_table_exists('privatemsg_block_user')) {
        $ret[] = update_sql('CREATE TABLE {privatemsg_block_user} (
            author int unsigned NOT NULL,
            recipient int unsigned NOT NULL,
            PRIMARY KEY (author, recipient)
          )  /*!40100 DEFAULT CHARACTER SET utf8 */');
      }
      break;
    case 'pgsql':
      db_add_column($ret, 'privatemsg', 'type', 'varchar(255)', array(
        'not null' => TRUE,
        'default' => "''",
      ));
      $ret[] = update_sql("CREATE INDEX {privatemsg_folder_type} ON {privatemsg}(type)");
      db_change_column($ret, 'privatemsg', 'subject', 'subject', 'varchar(255)', array(
        'not null' => TRUE,
        'default' => "''",
      ));
      if (!db_table_exists('privatemsg_block_user')) {
        $ret[] = update_sql('CREATE TABLE {privatemsg_block_user} (
            author int unsigned NOT NULL,
            recipient int unsigned NOT NULL,
            PRIMARY KEY (author, recipient)
          )');
      }
      break;
  }
  return $ret;
}