'id', 'privatemsg_folder' => 'fid') as $table => $id) { $ret[] = update_sql(sprintf($sql, $table, $id)); $max = db_result(db_query('SELECT max('. $id .') FROM {'. $table .'}')); if ($table == 'privatemsg') { $max = max($max, db_result(db_query('SELECT max(id) FROM {privatemsg_archive}'))); } $ret[] = update_sql(sprintf($seq, '{'. $table .'}_'. $id, $max)); } $ret[] = update_sql(sprintf($sql, 'privatemsg_archive', 'id')); return $ret; } function privatemsg_update_3() { $ret = array(); switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': $ret[] = update_sql('ALTER TABLE {privatemsg} ADD thread int NOT NULL'); $ret[] = update_sql('ALTER TABLE {privatemsg_archive} ADD thread int NOT NULL'); break; case 'pgsql': foreach (array('privatemsg', 'privatemsg_archive') as $table) { $ret[] = update_sql("ALTER TABLE {$table} ADD thread int"); $ret[] = update_sql("ALTER TABLE {$table} ALTER COLUMN thread SET DEFAULT 0"); $ret[] = update_sql("UPDATE {$table} SET thread = 0"); $ret[] = update_sql("ALTER TABLE {$table} ALTER COLUMN thread SET NOT NULL"); } break; } return $ret; } 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; } /** * Add variables column for use by the subscriptions module. */ function privatemsg_update_5() { $ret = array(); switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': $ret[] = update_sql("ALTER TABLE {privatemsg} ADD variables longtext"); break; case 'pgsql': db_add_column($ret, 'privatemsg', 'variables', 'text'); break; } return $ret; }