• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visavi / rotor / 26727161334

31 May 2026 11:08PM UTC coverage: 14.072% (-0.1%) from 14.172%
26727161334

push

github

visavi
Поправил возврат ошибки для api

790 of 5614 relevant lines covered (14.07%)

2.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.56
/app/Http/Controllers/Admin/UpgradeController.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace App\Http\Controllers\Admin;
6

7
use App\Services\GithubService;
8
use App\Services\MigrationService;
9
use Illuminate\Http\JsonResponse;
10
use Illuminate\Http\RedirectResponse;
11
use Illuminate\Http\Request;
12
use Illuminate\Support\Facades\Artisan;
13
use Illuminate\View\View;
14

15
class UpgradeController extends AdminController
16
{
17
    public function __construct(private readonly MigrationService $migrations)
6✔
18
    {
19
    }
6✔
20

21
    public function index(GithubService $githubService): View
×
22
    {
23
        $latestRelease = $githubService->getLatestRelease();
×
24
        $latestVersion = $githubService->getLatestVersionClean();
×
25

26
        $hasNewVersion = version_compare(ROTOR_VERSION, $latestVersion, '<');
×
27
        $pendingMigrations = $this->migrations->getPendingMigrations($this->paths());
×
28

29
        return view('admin/upgrade/index', compact('hasNewVersion', 'latestRelease', 'pendingMigrations'));
×
30
    }
31

32
    public function migrate(Request $request): JsonResponse|RedirectResponse
×
33
    {
34
        Artisan::call('migrate', ['--force' => true]);
×
35
        $output = Artisan::output();
×
36

37
        if ($request->ajax()) {
×
38
            return response()->json(['output' => $output]);
×
39
        }
40

41
        return redirect()->route('admin.upgrade.index')->with('migrateOutput', $output);
×
42
    }
43

44
    public function migrateNext(): JsonResponse
×
45
    {
46
        ini_set('max_execution_time', 0);
×
47
        set_time_limit(0);
×
48

49
        $pending = $this->migrations->getPendingMigrations($this->paths());
×
50

51
        if (empty($pending)) {
×
52
            Artisan::call('cache:clear');
×
53
            Artisan::call('route:clear');
×
54
            Artisan::call('config:clear');
×
55

56
            return response()->json(['done' => true, 'migration' => null, 'output' => '']);
×
57
        }
58

59
        $name = $pending[0];
×
60
        $file = $this->migrations->findFile($name);
×
61

62
        if (! $file) {
×
63
            return response()->json(['error' => "Файл миграции не найден: {$name}"], 500);
×
64
        }
65

66
        $remaining = count($pending) - 1;
×
67

68
        return response()->json([
×
69
            'done'      => $remaining === 0,
×
70
            'migration' => $name,
×
71
            'output'    => $this->migrations->runOne($file),
×
72
            'remaining' => $remaining,
×
73
        ]);
×
74
    }
75

76
    private function paths(): array
×
77
    {
78
        return [database_path('migrations'), database_path('upgrades')];
×
79
    }
80
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc