[ 'host_scope CHAR(64)', 'vm_uuid CHAR(36)', 'host_id VARCHAR(64)', 'user_id BIGINT UNSIGNED', 'network_rx_bytes BIGINT UNSIGNED', 'network_tx_bytes BIGINT UNSIGNED', 'vm_metric_owner (user_id, host_id, sampled_at)', ], 'cloud_vm_traffic_totals' => [ 'network_signature CHAR(64)', 'network_baseline_json JSON', 'download_rx_bytes BIGINT UNSIGNED', 'upload_tx_bytes BIGINT UNSIGNED', 'vm_traffic_owner (user_id, host_id)', ], 'cloud_vm_traffic_checkpoints' => [ 'checkpoint_hour BIGINT UNSIGNED', 'first_observed_at BIGINT UNSIGNED', 'vm_traffic_checkpoint_owner (user_id, host_id, first_observed_at)', ], 'cloud_vm_daily_traffic_cursors' => [ 'instance_id BIGINT UNSIGNED', 'user_id BIGINT UNSIGNED', 'last_observed_at BIGINT UNSIGNED', 'download_total_bytes BIGINT UNSIGNED', 'upload_total_bytes BIGINT UNSIGNED', 'cloud_daily_traffic_cursor_owner (user_id, updated_at)', ], 'cloud_vm_daily_traffic' => [ 'instance_id BIGINT UNSIGNED', 'user_id BIGINT UNSIGNED', 'day_start BIGINT UNSIGNED', 'download_bytes BIGINT UNSIGNED', 'upload_bytes BIGINT UNSIGNED', 'sample_count INT UNSIGNED', 'cloud_daily_traffic_retention (day_start)', 'cloud_daily_traffic_owner (user_id, day_start)', ], ] as $table => $required) { $assert(preg_match('/CREATE TABLE ' . preg_quote($table, '/') . '\s*\((.*?)\) ENGINE=/s', $sql, $match) === 1, 'Missing fresh log table: ' . $table); foreach ($required as $fragment) { $assert(str_contains($match[1], $fragment), $table . ' is missing: ' . $fragment); } } $assert(preg_match('/\b(?:ALTER|DROP)\s+TABLE\b/i', $sql) !== 1, 'Fresh cloud log schema contains migration/destructive DDL.'); $assert(!str_contains($sql, 'engine_vm_'), 'Fresh cloud log schema retained an engine-prefixed table.'); echo "Fresh-install Agent metric and traffic DDL contract passed.\n";