function privatemsg_update_2 in Privatemsg 5.3
Same name and namespace in other branches
- 5 privatemsg.install \privatemsg_update_2()
File
- ./
privatemsg.install, line 176
Code
function privatemsg_update_2() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$sql = 'ALTER TABLE {%s} MODIFY %s int unsigned NOT NULL';
$seq = "INSERT INTO {sequences} (name, id) VALUES ('%s', %d)";
break;
case 'pgsql':
$sql = 'ALTER TABLE {%s} ALTER COLUMN %s SET DEFAULT NULL';
$seq = 'CREATE SEQUENCE %s_seq INCREMENT 1 START %d';
break;
default:
return $ret;
}
foreach (array(
'privatemsg' => '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;
}