summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics
diff options
context:
space:
mode:
authorSimon Rettberg2019-04-03 18:10:28 +0200
committerSimon Rettberg2019-04-03 18:10:28 +0200
commit4d51d90809da34022991e4a8c17caeb28c31bde0 (patch)
treee790d751fbb5883023aaf130f157f4fc23c09c1b /modules-available/statistics
parent[serversetup-bwlp-ipxe] Fix resetting of default bootentries on install (diff)
downloadslx-admin-4d51d90809da34022991e4a8c17caeb28c31bde0.tar.gz
slx-admin-4d51d90809da34022991e4a8c17caeb28c31bde0.tar.xz
slx-admin-4d51d90809da34022991e4a8c17caeb28c31bde0.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')
-rw-r--r--modules-available/statistics/install.inc.php11
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')) {