Zone: rename parent_zone to parent

This commit is contained in:
Thomas Gelf 2015-12-15 15:13:25 +01:00
parent 1a76bc0b1f
commit 0c68677fa5
5 changed files with 19 additions and 20 deletions

View File

@ -26,7 +26,7 @@ class IcingaZoneForm extends DirectorObjectForm
'required' => true, 'required' => true,
)); ));
$this->addElement('select', 'parent_zone_id', array( $this->addElement('select', 'parent_id', array(
'label' => $this->translate('Parent Zone'), 'label' => $this->translate('Parent Zone'),
'description' => $this->translate('Chose an (optional) parent zone'), 'description' => $this->translate('Chose an (optional) parent zone'),
'multiOptions' => $this->optionalEnum($this->db->enumZones()) 'multiOptions' => $this->optionalEnum($this->db->enumZones())

View File

@ -170,7 +170,7 @@ constants
public function getZoneObjects() public function getZoneObjects()
{ {
return $this->getDirectorObjects('Zone', 'Zone', 'zones', array( return $this->getDirectorObjects('Zone', 'Zone', 'zones', array(
'parent' => 'parent_zone', 'parent' => 'parent',
'global' => 'is_global', 'global' => 'is_global',
)); ));
} }

View File

@ -9,11 +9,11 @@ class IcingaZone extends IcingaObject
protected $table = 'icinga_zone'; protected $table = 'icinga_zone';
protected $defaultProperties = array( protected $defaultProperties = array(
'id' => null, 'id' => null,
'object_name' => null, 'object_name' => null,
'object_type' => null, 'object_type' => null,
'parent_zone_id' => null, 'parent_id' => null,
'is_global' => 'n', 'is_global' => 'n',
); );
protected $booleans = array( protected $booleans = array(
@ -22,7 +22,7 @@ class IcingaZone extends IcingaObject
); );
protected $relations = array( protected $relations = array(
'parent_zone' => 'IcingaZone', 'parent' => 'IcingaZone',
); );
protected $supportsImports = true; protected $supportsImports = true;
@ -48,13 +48,4 @@ class IcingaZone extends IcingaObject
return $db->fetchCol($query); return $db->fetchCol($query);
} }
protected function renderParent_zone_id()
{
return $this->renderRelationProperty(
'parent_zone',
$this->parent_zone_id,
'parent'
);
}
} }

View File

@ -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;

View File

@ -146,14 +146,14 @@ CREATE TABLE director_datafield_setting (
CREATE TABLE icinga_zone ( CREATE TABLE icinga_zone (
id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, 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_name VARCHAR(255) NOT NULL,
object_type ENUM('object', 'template', 'external_object') NOT NULL, object_type ENUM('object', 'template', 'external_object') NOT NULL,
is_global ENUM('y', 'n') NOT NULL DEFAULT 'n', is_global ENUM('y', 'n') NOT NULL DEFAULT 'n',
PRIMARY KEY (id), PRIMARY KEY (id),
UNIQUE INDEX object_name (object_name), UNIQUE INDEX object_name (object_name),
CONSTRAINT icinga_zone_parent_zone CONSTRAINT icinga_zone_parent
FOREIGN KEY parent_zone (parent_zone_id) FOREIGN KEY parent_zone (parent_id)
REFERENCES icinga_zone (id) REFERENCES icinga_zone (id)
ON DELETE RESTRICT ON DELETE RESTRICT
ON UPDATE CASCADE ON UPDATE CASCADE