make(Kernel::class)->bootstrap(); $db = $app->make('db')->connection(); $db->beginTransaction(); try { $db->statement('SET TRANSACTION READ ONLY'); $preview = $app->make(OpportunityResourceInstallation::class)->preview(); $proofPath = storage_path('app/private/investmoz-v2/opportunity-resources-activation-proof.json'); $proof = is_file($proofPath) ? json_decode(file_get_contents($proofPath), true, 512, JSON_THROW_ON_ERROR) : []; $result = [ 'captured_at' => gmdate('c'), 'read_only' => $db->selectOne("SELECT current_setting('transaction_read_only') AS value")->value, 'installed' => $preview['installed'], 'ready' => $preview['ready'], 'target' => $preview['target'], 'current_code_hash' => $preview['code_hash'], 'proof_code_hash' => $proof['code_hash'] ?? null, 'code_matches_proof' => ($proof['code_hash'] ?? '') === $preview['code_hash'], 'backup_date' => $preview['backupDate'], 'active_writes' => 0, ]; file_put_contents(storage_path('app/private/investmoz-v2/opportunity-resources-readiness.json'), json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR)); echo json_encode($result, JSON_THROW_ON_ERROR).PHP_EOL; } finally { $db->rollBack(); }