Index: branches/5.0.x/core/install/upgrades.php =================================================================== diff -u -r12299 -r12422 --- branches/5.0.x/core/install/upgrades.php (.../upgrades.php) (revision 12299) +++ branches/5.0.x/core/install/upgrades.php (.../upgrades.php) (revision 12422) @@ -1,6 +1,6 @@ Conn->Query($sql); } } + + /** + * Update to 5.0.1 + * + * @param string $mode when called mode {before, after) + */ + function Upgrade_5_0_1($mode) + { + if ($mode == 'after') { + + // delete old events + $events_to_delete = Array ( '"CATEGORY.MODIFY"', '"CATEGORY.DELETE"' ); + $sql = 'SELECT EventId + FROM ' . TABLE_PREFIX . 'Events + WHERE Event IN (' . implode(',', $events_to_delete) . ')'; + $event_ids = $this->Conn->GetCol($sql); + + if ($event_ids) { + $sql = 'DELETE FROM EmailMessages WHERE EventId IN (' . implode(',', $event_ids) . ')'; + $this->Conn->Query($sql); + + $sql = 'DELETE FROM Events WHERE EventId IN (' . implode(',', $event_ids) . ')'; + $this->Conn->Query($sql); + } + } + } + } \ No newline at end of file