From 0c68677fa5e10f37f39c379a3313d4a67a27a0ec Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 15 Dec 2015 15:13:25 +0100 Subject: [PATCH] Zone: rename parent_zone to parent --- application/forms/IcingaZoneForm.php | 2 +- library/Director/Core/CoreApi.php | 2 +- library/Director/Objects/IcingaZone.php | 21 ++++++--------------- schema/mysql-changes/upgrade_55.sql | 8 ++++++++ schema/mysql.sql | 6 +++--- 5 files changed, 19 insertions(+), 20 deletions(-) create mode 100644 schema/mysql-changes/upgrade_55.sql diff --git a/application/forms/IcingaZoneForm.php b/application/forms/IcingaZoneForm.php index 33cbce4b..4e4f4222 100644 --- a/application/forms/IcingaZoneForm.php +++ b/application/forms/IcingaZoneForm.php @@ -26,7 +26,7 @@ class IcingaZoneForm extends DirectorObjectForm 'required' => true, )); - $this->addElement('select', 'parent_zone_id', array( + $this->addElement('select', 'parent_id', array( 'label' => $this->translate('Parent Zone'), 'description' => $this->translate('Chose an (optional) parent zone'), 'multiOptions' => $this->optionalEnum($this->db->enumZones()) diff --git a/library/Director/Core/CoreApi.php b/library/Director/Core/CoreApi.php index 104f3606..1222d876 100644 --- a/library/Director/Core/CoreApi.php +++ b/library/Director/Core/CoreApi.php @@ -170,7 +170,7 @@ constants public function getZoneObjects() { return $this->getDirectorObjects('Zone', 'Zone', 'zones', array( - 'parent' => 'parent_zone', + 'parent' => 'parent', 'global' => 'is_global', )); } diff --git a/library/Director/Objects/IcingaZone.php b/library/Director/Objects/IcingaZone.php index 5042079c..6fd7f761 100644 --- a/library/Director/Objects/IcingaZone.php +++ b/library/Director/Objects/IcingaZone.php @@ -9,11 +9,11 @@ class IcingaZone extends IcingaObject protected $table = 'icinga_zone'; protected $defaultProperties = array( - 'id' => null, - 'object_name' => null, - 'object_type' => null, - 'parent_zone_id' => null, - 'is_global' => 'n', + 'id' => null, + 'object_name' => null, + 'object_type' => null, + 'parent_id' => null, + 'is_global' => 'n', ); protected $booleans = array( @@ -22,7 +22,7 @@ class IcingaZone extends IcingaObject ); protected $relations = array( - 'parent_zone' => 'IcingaZone', + 'parent' => 'IcingaZone', ); protected $supportsImports = true; @@ -48,13 +48,4 @@ class IcingaZone extends IcingaObject return $db->fetchCol($query); } - - protected function renderParent_zone_id() - { - return $this->renderRelationProperty( - 'parent_zone', - $this->parent_zone_id, - 'parent' - ); - } } diff --git a/schema/mysql-changes/upgrade_55.sql b/schema/mysql-changes/upgrade_55.sql new file mode 100644 index 00000000..4ad6feb2 --- /dev/null +++ b/schema/mysql-changes/upgrade_55.sql @@ -0,0 +1,8 @@ +ALTER TABLE icinga_zone + DROP FOREIGN KEY icinga_zone_parent_zone, + CHANGE parent_zone_id parent_id INT(10) UNSIGNED DEFAULT NULL, + ADD CONSTRAINT icinga_zone_parent + FOREIGN KEY parent_zone (parent_id) + REFERENCES icinga_zone (id) + ON DELETE RESTRICT + ON UPDATE CASCADE; diff --git a/schema/mysql.sql b/schema/mysql.sql index c972e519..dbc55076 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -146,14 +146,14 @@ CREATE TABLE director_datafield_setting ( CREATE TABLE icinga_zone ( id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, - parent_zone_id INT(10) UNSIGNED DEFAULT NULL, + parent_id INT(10) UNSIGNED DEFAULT NULL, object_name VARCHAR(255) NOT NULL, object_type ENUM('object', 'template', 'external_object') NOT NULL, is_global ENUM('y', 'n') NOT NULL DEFAULT 'n', PRIMARY KEY (id), UNIQUE INDEX object_name (object_name), - CONSTRAINT icinga_zone_parent_zone - FOREIGN KEY parent_zone (parent_zone_id) + CONSTRAINT icinga_zone_parent + FOREIGN KEY parent_zone (parent_id) REFERENCES icinga_zone (id) ON DELETE RESTRICT ON UPDATE CASCADE