moved adoption history from logentries to new table; added adoption history to admin cache history

This commit is contained in:
following
2013-06-10 20:11:31 +02:00
parent 1864d8906c
commit 0718e8a311
7 changed files with 117 additions and 1 deletions

View File

@@ -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.
}
}
?>