From 4420d76cd22c8cb0ed28803298e4ffaf33363e85 Mon Sep 17 00:00:00 2001 From: Jeppe Bundgaard Date: Thu, 23 Apr 2026 15:50:30 +0200 Subject: [PATCH] Add "stage" field and additional JSON payloads to Edge Gateway operation events schema --- .../classes/edge_gateway_operation_service.php | 10 ++++++++++ .../classes/edge_gateway_schema_bootstrap.php | 8 ++++++++ .../app/objects/edge_gateway_operation_events_o.php | 3 +++ 3 files changed, 21 insertions(+) diff --git a/services/nginx/app/modules/edgegateway/classes/edge_gateway_operation_service.php b/services/nginx/app/modules/edgegateway/classes/edge_gateway_operation_service.php index 18427816..4f72fcde 100644 --- a/services/nginx/app/modules/edgegateway/classes/edge_gateway_operation_service.php +++ b/services/nginx/app/modules/edgegateway/classes/edge_gateway_operation_service.php @@ -924,9 +924,19 @@ class edge_gateway_operation_service string $message, array $context ): array { + $stage = trim((string)($context['stage'] ?? '')); + if ($stage === '') { + $operation = (new edge_gateway_operations_o())->select($operationId); + $stage = trim((string)($operation->status->value() ?? '')); + } + if ($stage === '') { + $stage = 'RECORDED'; + } + $eventId = (new edge_gateway_operation_events_o())->add_object([ 'operation_id' => $operationId, 'gateway_id' => $gatewayId, + 'stage' => $stage, 'level' => $level, 'code' => $code, 'message' => $message, diff --git a/services/nginx/app/modules/edgegateway/classes/edge_gateway_schema_bootstrap.php b/services/nginx/app/modules/edgegateway/classes/edge_gateway_schema_bootstrap.php index b7026700..1649cb28 100644 --- a/services/nginx/app/modules/edgegateway/classes/edge_gateway_schema_bootstrap.php +++ b/services/nginx/app/modules/edgegateway/classes/edge_gateway_schema_bootstrap.php @@ -157,11 +157,15 @@ class edge_gateway_schema_bootstrap id INT AUTO_INCREMENT PRIMARY KEY, operation_id INT NOT NULL, gateway_id INT NOT NULL, + stage VARCHAR(64) NOT NULL DEFAULT 'RECORDED', level VARCHAR(16) NOT NULL DEFAULT 'INFO', code VARCHAR(128) NULL, message TEXT NOT NULL, context_json JSON NULL, + counts_json JSON NULL, + payload_json JSON NULL, created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP NULL DEFAULT NULL, INDEX idx_edge_gateway_operation_events_operation (operation_id), INDEX idx_edge_gateway_operation_events_gateway (gateway_id), INDEX idx_edge_gateway_operation_events_level (level) @@ -254,8 +258,12 @@ class edge_gateway_schema_bootstrap self::ensureColumn('edge_gateway_operations', 'updated_at', 'TIMESTAMP NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP AFTER created_at'); self::ensureColumn('edge_gateway_operations', 'deleted_at', 'TIMESTAMP NULL DEFAULT NULL AFTER updated_at'); + self::ensureColumn('edge_gateway_operation_events', 'stage', "VARCHAR(64) NOT NULL DEFAULT 'RECORDED' AFTER gateway_id"); self::ensureColumn('edge_gateway_operation_events', 'code', 'VARCHAR(128) NULL AFTER level'); self::ensureColumn('edge_gateway_operation_events', 'context_json', 'JSON NULL AFTER message'); + self::ensureColumn('edge_gateway_operation_events', 'counts_json', 'JSON NULL AFTER context_json'); + self::ensureColumn('edge_gateway_operation_events', 'payload_json', 'JSON NULL AFTER counts_json'); + self::ensureColumn('edge_gateway_operation_events', 'deleted_at', 'TIMESTAMP NULL DEFAULT NULL AFTER created_at'); self::ensureColumn('edge_gateway_audit_logs', 'actor_type', "VARCHAR(32) NOT NULL DEFAULT 'USER' AFTER actor_user_id"); self::ensureColumn('edge_gateway_audit_logs', 'severity', "VARCHAR(16) NOT NULL DEFAULT 'INFO' AFTER actor_type"); diff --git a/services/nginx/app/objects/edge_gateway_operation_events_o.php b/services/nginx/app/objects/edge_gateway_operation_events_o.php index e1a684b8..9d36d8f1 100644 --- a/services/nginx/app/objects/edge_gateway_operation_events_o.php +++ b/services/nginx/app/objects/edge_gateway_operation_events_o.php @@ -13,6 +13,7 @@ class edge_gateway_operation_events_o extends db public object_property $operation_id; public object_property $gateway_id; + public object_property $stage; public object_property $level; public object_property $code; public object_property $message; @@ -29,6 +30,7 @@ class edge_gateway_operation_events_o extends db { $this->operation_id = new object_property($this->table, $this->id, 'operation_id', 'int', false); $this->gateway_id = new object_property($this->table, $this->id, 'gateway_id', 'int', false); + $this->stage = new object_property($this->table, $this->id, 'stage', 'string', false); $this->level = new object_property($this->table, $this->id, 'level', 'string', false); $this->code = new object_property($this->table, $this->id, 'code', 'string', false); $this->message = new object_property($this->table, $this->id, 'message', 'text', false); @@ -48,6 +50,7 @@ class edge_gateway_operation_events_o extends db 'id' => (int)$this->id, 'operation_id' => (int)$this->operation_id->value(), 'gateway_id' => (int)$this->gateway_id->value(), + 'stage' => (string)$this->stage->value(), 'level' => (string)$this->level->value(), 'code' => $this->code->value() === null ? null : (string)$this->code->value(), 'message' => (string)$this->message->value(),