make(Kernel::class)->bootstrap(); if (! $app->environment('local') || DB::connection()->getDriverName() !== 'pgsql') { throw new RuntimeException('Local PostgreSQL only.'); } $manifest = $argv[1] ?? ''; if (! is_file($manifest)) { throw new RuntimeException('Provide the private backup manifest path.'); } $before = json_decode(file_get_contents($manifest), true, 512, JSON_THROW_ON_ERROR)['row_counts']; $result = DB::transaction(function () use ($before): array { DB::statement('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ ONLY'); $changes = []; foreach ($before as $table => $count) { $after = DB::table($table)->count(); if ($after !== $count) { $changes[$table] = ['before' => $count, 'after' => $after]; } } $new = []; foreach (['existing_businesses', 'existing_business_objects', 'existing_business_mandates', 'existing_business_revisions', 'existing_business_reviews'] as $table) { $new[$table] = DB::table($table)->count(); } return ['previous_tables' => count($before), 'changes' => $changes, 'new_tables' => $new, 'private_module_enabled' => (bool) config('existing-business.enabled'), 'designated_reviewer_count' => count(config('existing-business.reviewers', []))]; }); echo json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR).PHP_EOL;