make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap(); \App\Shared\Testing\TestingDatabaseGuard::assertSafe(); $counts = []; foreach (['a_clients','a_services','a_service_drafts','a_billing_drafts','a_history','a_events','a_outbox','a_pending','a_commands'] as $table) { $counts[$table] = \Illuminate\Support\Facades\DB::table($table)->count(); } $missing = \Illuminate\Support\Facades\DB::table('a_events as e')->leftJoin('a_outbox as o', 'o.event_id', '=', 'e.id')->whereNull('o.event_id')->count(); if ($missing !== 0 || $counts['a_history'] !== $counts['a_events'] || $counts['a_events'] !== $counts['a_outbox']) { throw new RuntimeException('Incomplete durable capture.'); } $report = ['database' => 'sgf_tempo_test', 'counts' => $counts, 'events_without_outbox' => $missing, 'outbox_states' => \Illuminate\Support\Facades\DB::table('a_outbox')->distinct()->pluck('state')->all()]; file_put_contents(base_path('docs/proofs/a-durable-capture.json'), json_encode($report, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR)); echo json_encode($report, JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR).PHP_EOL;