Add "stage" field and additional JSON payloads to Edge Gateway operation events schema

This commit is contained in:
Jeppe Bundgaard
2026-04-23 15:50:30 +02:00
parent b9ddc585db
commit 4420d76cd2
3 changed files with 21 additions and 0 deletions
@@ -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,
@@ -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");
@@ -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(),