diff options
author | Simon Rettberg | 2019-04-03 18:10:28 +0200 |
---|---|---|
committer | Simon Rettberg | 2019-04-03 18:11:43 +0200 |
commit | 6e89e15c7844afe054ca9c214e200a44e23e1a78 (patch) | |
tree | c38ad51c578cafa71c52bd6efae346495cccaa49 /modules-available/statistics/install.inc.php | |
parent | [locationinfo] Style checkboxes, use icon in save button (diff) | |
download | slx-admin-6e89e15c7844afe054ca9c214e200a44e23e1a78.tar.gz slx-admin-6e89e15c7844afe054ca9c214e200a44e23e1a78.tar.xz slx-admin-6e89e15c7844afe054ca9c214e200a44e23e1a78.zip |
[statistics/locations] Add locationid constraints; update on delete
We didn't update subnetlocationid when deleting a location,
leading to machines pointing to invalid locations.
Diffstat (limited to 'modules-available/statistics/install.inc.php')
-rw-r--r-- | modules-available/statistics/install.inc.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules-available/statistics/install.inc.php b/modules-available/statistics/install.inc.php index 090f0617..2bcb6b8d 100644 --- a/modules-available/statistics/install.inc.php +++ b/modules-available/statistics/install.inc.php @@ -196,6 +196,8 @@ if ($addTrigger) { if (Module::isAvailable('locations')) { if (tableExists('subnet')) { AutoLocation::rebuildAll(); + } else { + $res[] = UPDATE_RETRY; } } $res[] = UPDATE_DONE; @@ -205,6 +207,15 @@ $res[] = tableAddConstraint('machine_x_hw', 'hwid', 'statistic_hw', 'hwid', 'ON $res[] = tableAddConstraint('machine_x_hw', 'machineuuid', 'machine', 'machineuuid', 'ON DELETE CASCADE ON UPDATE CASCADE'); $res[] = tableAddConstraint('machine_x_hw_prop', 'machinehwid', 'machine_x_hw', 'machinehwid', 'ON DELETE CASCADE'); $res[] = tableAddConstraint('statistic_hw_prop', 'hwid', 'statistic_hw', 'hwid', 'ON DELETE CASCADE'); +if (Module::isAvailable('locations')) { + if (tableExists('location')) { + $res[] = tableAddConstraint('machine', 'fixedlocationid', 'location', 'locationid', + 'ON UPDATE CASCADE ON DELETE SET NULL'); + // No constraint for subnetlocationid -- needs recalc anyways (AutoLocation::rebuildAll()) + } else { + $res[] = UPDATE_RETRY; + } +} // 2017-11-27: Add state column if (!tableHasColumn('machine', 'state')) { |