4
|
1 #!/usr/bin/php |
|
2 <?php |
|
3 chdir(__DIR__); |
|
4 require_once './common.php'; |
|
5 |
|
6 docleanup('Orphaned peergroups', 'DELETE FROM `peergroups` WHERE `group` NOT IN (SELECT `id` FROM `groups`)'); |
|
7 docleanup('Orphaned peergroups', 'DELETE FROM `peergroups` WHERE `peer` NOT IN (SELECT `id` FROM `peers`)'); |
|
8 docleanup('Orphaned groupmessages', 'DELETE FROM `groupmessages` WHERE `group` NOT IN (SELECT `id` FROM `groups`)'); |
|
9 docleanup('Orphaned messages', 'DELETE FROM `messages` WHERE `id` NOT IN (SELECT `message` FROM `groupmessages`)'); |
|
10 docleanup('Orphaned groupmessages', 'DELETE FROM `groupmessages` WHERE `message` NOT IN (SELECT `id` FROM `messages`)'); |
|
11 docleanup('Optimize', 'OPTIMIZE TABLE `groupmessages`, `groups`, `messages`, `peergroups`, `peer`'); |
|
12 |
|
13 function docleanup($comment, $query) { |
|
14 global $db; |
|
15 $count = $db->update($query); |
|
16 print($comment.': '.$count."\n"); |
|
17 } |