aboutsummaryrefslogtreecommitdiff
path: root/backend/database/dev/backup/update_002_add_asset_relationships.sql
diff options
context:
space:
mode:
authorUMTS at Teleco <crt@teleco.ch>2026-01-11 19:58:54 +0100
committerUMTS at Teleco <crt@teleco.ch>2026-01-11 19:58:54 +0100
commit7b57e2df69eccbc0fe78f119e25e58bee18f576d (patch)
tree8dc88ffeeb1d9da829f32c4132511db0d704adab /backend/database/dev/backup/update_002_add_asset_relationships.sql
parent0c7c41f8586378511633b19d44510318108b2bf7 (diff)
cleanup time
Diffstat (limited to 'backend/database/dev/backup/update_002_add_asset_relationships.sql')
-rw-r--r--backend/database/dev/backup/update_002_add_asset_relationships.sql11
1 files changed, 11 insertions, 0 deletions
diff --git a/backend/database/dev/backup/update_002_add_asset_relationships.sql b/backend/database/dev/backup/update_002_add_asset_relationships.sql
new file mode 100644
index 0000000..0d74b89
--- /dev/null
+++ b/backend/database/dev/backup/update_002_add_asset_relationships.sql
@@ -0,0 +1,11 @@
+ALTER TABLE `assets`
+ADD COLUMN `belongs_to_item` INT(11) DEFAULT NULL COMMENT 'References asset_numeric_id of parent asset' AFTER `asset_numeric_id`,
+ADD COLUMN `previously_was` INT(11) DEFAULT NULL COMMENT 'References asset_numeric_id of the asset this replaced' AFTER `belongs_to_item`;
+
+ALTER TABLE `assets`
+ADD KEY `idx_belongs_to` (`belongs_to_item`),
+ADD KEY `idx_previously_was` (`previously_was`);
+
+ALTER TABLE `assets`
+ADD CONSTRAINT `fk_assets_belongs_to` FOREIGN KEY (`belongs_to_item`) REFERENCES `assets` (`asset_numeric_id`) ON DELETE SET NULL,
+ADD CONSTRAINT `fk_assets_previously_was` FOREIGN KEY (`previously_was`) REFERENCES `assets` (`asset_numeric_id`) ON DELETE SET NULL;