Files
librenms-librenms/upgrade-scripts/fix-events.php

21 lines
591 B
PHP
Raw Normal View History

<?php
2014-01-13 17:43:58 +00:00
// MYSQL Check - FIXME
// 3 ALTERS
// 1 SELECT
// 1 UPDATE
2015-07-13 20:10:26 +02:00
mysql_query('ALTER TABLE `eventlog` DROP `id`');
mysql_query('ALTER TABLE `eventlog` ADD `event_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST');
2014-01-13 17:43:58 +00:00
2015-07-13 20:10:26 +02:00
$s = 'SELECT * FROM eventlog';
$q = mysql_query($s);
2015-07-13 20:10:26 +02:00
while ($event = mysql_fetch_assoc($q)) {
if ($event['interface']) {
mysql_query("UPDATE `eventlog` SET `interface` = NULL, `type` = 'interface', `reference` = '".$event['interface']."' WHERE `event_id` = '".$event['event_id']."'");
}
2015-07-13 20:10:26 +02:00
$i++;
}
2015-07-13 20:10:26 +02:00
mysql_query('ALTER TABLE `eventlog` DROP `interface`');