moved adoption history from logentries to new table; added adoption history to admin cache history
This commit is contained in:
@@ -187,4 +187,40 @@
|
||||
sql("ALTER TABLE `user` ADD COLUMN `first_email_problem` date default NULL AFTER `email_problems`");
|
||||
}
|
||||
|
||||
function dbv_110() // move adoption history to separate table
|
||||
{
|
||||
if (!sql_table_exists('cache_adoptions'))
|
||||
{
|
||||
sql(
|
||||
"CREATE TABLE `cache_adoptions` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cache_id` int(10) unsigned NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`from_user_id` int(10) unsigned NOT NULL,
|
||||
`to_user_id` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `cache_id` (`cache_id`,`date`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
|
||||
|
||||
$rs = sql("SELECT `id`, `date_created`, `objectid1`, `logtext`
|
||||
FROM `logentries`
|
||||
WHERE `eventid`=5
|
||||
ORDER BY `date_created`, `id`");
|
||||
while ($rLog = sql_fetch_assoc($rs))
|
||||
{
|
||||
preg_match('/Cache (\d+) has changed the owner from userid (\d+) to (\d+) by (\d+)/',
|
||||
$rLog['logtext'], $matches);
|
||||
if (count($matches) != 5)
|
||||
die("unknown adoption log entry format for ID " . $rLog['id'] . "\n");
|
||||
sql("INSERT INTO `cache_adoptions`
|
||||
(`cache_id`,`date`,`from_user_id`,`to_user_id`)
|
||||
VALUES ('&1','&2','&3','&4')",
|
||||
$rLog['objectid1'], $rLog['date_created'], $matches[2], $matches[3]);
|
||||
}
|
||||
sql_free_result($rs);
|
||||
|
||||
// We keep the old entries in 'logentries' for the case something went wrong here.
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user