mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 16:24:05 +02:00
Housekeeping: wipe obsolete imported data
This commit is contained in:
parent
33d323286e
commit
12e849d2a4
@ -71,4 +71,30 @@ class Housekeeping
|
||||
|
||||
return $this->db->exec($sql);
|
||||
}
|
||||
|
||||
public function wipeUnusedImportedRowsAndProperties()
|
||||
{
|
||||
$queries = array(
|
||||
// This one removes imported_rowset and imported_rowset_row
|
||||
// entries no longer used by any historic import
|
||||
'DELETE rs.* FROM imported_rowset rs LEFT JOIN import_run r'
|
||||
. ' ON r.rowset_checksum = rs.checksum WHERE r.id IS NULL',
|
||||
|
||||
// This query removes imported_row and imported_row_property columns
|
||||
// without related rowset
|
||||
'DELETE r.* FROM imported_row r LEFT JOIN imported_rowset_row rsr'
|
||||
. ' ON rsr.row_checksum = r.checksum WHERE rsr.row_checksum IS NULL',
|
||||
|
||||
// This
|
||||
'DELETE p.* FROM imported_property p LEFT JOIN imported_row_property rp'
|
||||
. ' ON rp.property_checksum = p.checksum WHERE rp.property_checksum IS NULL'
|
||||
);
|
||||
|
||||
$count = 0;
|
||||
foreach ($queries as $sql) {
|
||||
$count += $this->db->exec($sql);
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user