From d0f29d36bbde59feff5ad4dbc482a0ebc21b8da4 Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Mon, 29 Jul 2019 14:41:58 +0200 Subject: [PATCH] Add depth to zone schema and remove zone_tree --- configobject/objecttypes/zone/zone.go | 3 +++ etc/schema/mysql/zone.sql | 11 +---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/configobject/objecttypes/zone/zone.go b/configobject/objecttypes/zone/zone.go index ae76ce5b..75359c02 100644 --- a/configobject/objecttypes/zone/zone.go +++ b/configobject/objecttypes/zone/zone.go @@ -18,6 +18,7 @@ var ( "name_ci", "is_global", "parent_id", + "depth", } ) @@ -31,6 +32,7 @@ type Zone struct { NameCi *string `json:"name_ci"` IsGlobal bool `json:"is_global"` ParentId string `json:"parent_id"` + Depth float64 `json:"depth"` } func NewZone() connection.Row { @@ -59,6 +61,7 @@ func (z *Zone) UpdateValues() []interface{} { z.NameCi, utils.Bool[z.IsGlobal], utils.Checksum(z.ParentId), + z.Depth, ) return v diff --git a/etc/schema/mysql/zone.sql b/etc/schema/mysql/zone.sql index 96324429..3c91a7c3 100644 --- a/etc/schema/mysql/zone.sql +++ b/etc/schema/mysql/zone.sql @@ -14,18 +14,9 @@ CREATE TABLE zone ( is_global enum('y','n') NOT NULL, parent_id binary(20) DEFAULT NULL COMMENT 'zone.id', + depth tinyint(3) unsigned NOT NULL, PRIMARY KEY (id), INDEX idx_parent_id (parent_id), UNIQUE INDEX idx_env_id_id (env_id,id) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; - -CREATE TABLE zone_tree ( - parent_id binary(20) NOT NULL COMMENT 'zone.id', - child_id binary(20) NOT NULL COMMENT 'zone.id', - env_id binary(20) NOT NULL COMMENT 'env.id', - depth tinyint(3) unsigned NOT NULL, - - PRIMARY KEY (child_id,depth), - UNIQUE INDEX zone_relation (child_id,parent_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC; \ No newline at end of file