From 93317bd021075f2f541b667e51802d7964169a46 Mon Sep 17 00:00:00 2001
From: UMTS at Teleco <crt@teleco.ch>
Date: Mon, 22 Dec 2025 11:06:06 +0100
Subject: item replacement and relationships db update

---
 backend/database/schema/beepzone-schema-dump.sql | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'backend/database/schema/beepzone-schema-dump.sql')

diff --git a/backend/database/schema/beepzone-schema-dump.sql b/backend/database/schema/beepzone-schema-dump.sql
index 3acb5e5..05d738a 100644
--- a/backend/database/schema/beepzone-schema-dump.sql
+++ b/backend/database/schema/beepzone-schema-dump.sql
@@ -28,7 +28,10 @@ CREATE TABLE `asset_change_log` (
 CREATE TABLE `assets` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `asset_tag` varchar(200) DEFAULT NULL,
+  `tag_generation_string` varchar(255) DEFAULT NULL,
   `asset_numeric_id` int(11) NOT NULL CHECK (`asset_numeric_id` between 10000000 and 99999999),
+  `belongs_to_item` int(11) DEFAULT NULL COMMENT 'References asset_numeric_id of parent asset',
+  `previously_was` int(11) DEFAULT NULL COMMENT 'References asset_numeric_id of the asset this replaced',
   `asset_type` enum('N','B','L','C') NOT NULL,
   `name` varchar(255) DEFAULT NULL,
   `category_id` int(11) DEFAULT NULL,
@@ -76,6 +79,8 @@ CREATE TABLE `assets` (
   KEY `last_modified_by` (`last_modified_by`),
   KEY `idx_asset_tag` (`asset_tag`),
   KEY `idx_asset_numeric` (`asset_numeric_id`),
+  KEY `idx_belongs_to` (`belongs_to_item`),
+  KEY `idx_previously_was` (`previously_was`),
   KEY `idx_type` (`asset_type`),
   KEY `idx_status` (`status`),
   KEY `idx_zone` (`zone_id`),
@@ -91,7 +96,9 @@ CREATE TABLE `assets` (
   CONSTRAINT `assets_ibfk_6` FOREIGN KEY (`audit_task_id`) REFERENCES `audit_tasks` (`id`) ON DELETE SET NULL,
   CONSTRAINT `assets_ibfk_7` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
   CONSTRAINT `assets_ibfk_8` FOREIGN KEY (`last_modified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
-  CONSTRAINT `fk_asset_label_template` FOREIGN KEY (`label_template_id`) REFERENCES `label_templates` (`id`) ON DELETE SET NULL
+  CONSTRAINT `fk_asset_label_template` FOREIGN KEY (`label_template_id`) REFERENCES `label_templates` (`id`) ON DELETE SET NULL,
+  CONSTRAINT `fk_assets_belongs_to` FOREIGN KEY (`belongs_to_item`) REFERENCES `assets` (`asset_numeric_id`) ON DELETE SET NULL,
+  CONSTRAINT `fk_assets_previously_was` FOREIGN KEY (`previously_was`) REFERENCES `assets` (`asset_numeric_id`) ON DELETE SET NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci;
 /*!40101 SET character_set_client = @saved_cs_client */;
 /*!50003 SET @saved_cs_client      = @@character_set_client */ ;
-- 
cgit v1.2.3-70-g09d2

