make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap(); $db = \Illuminate\Support\Facades\DB::selectOne('SELECT current_database() AS db, current_user AS role'); $counts = []; foreach (['users', 'tenants', 'companies', 'units', 'company_memberships', 'permission_grants', 'identity_audit'] as $table) { $counts[$table] = \Illuminate\Support\Facades\Schema::hasTable($table) ? \Illuminate\Support\Facades\DB::table($table)->count() : 'pending migration'; } echo json_encode(['database' => $db->db, 'role' => $db->role, 'counts' => $counts], JSON_PRETTY_PRINT).PHP_EOL;