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

tempestphp / tempest-framework / 14140550176

28 Mar 2025 10:29PM UTC coverage: 80.716% (+1.4%) from 79.334%
14140550176

push

github

web-flow
feat(support): support `$default` on array `first` and `last` methods (#1096)

11 of 12 new or added lines in 2 files covered. (91.67%)

135 existing lines in 16 files now uncovered.

10941 of 13555 relevant lines covered (80.72%)

100.32 hits per line

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

89.47
/src/Tempest/Framework/Commands/MigrateFreshCommand.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Framework\Commands;
6

7
use Tempest\Console\Console;
8
use Tempest\Console\ConsoleArgument;
9
use Tempest\Console\ConsoleCommand;
10
use Tempest\Console\ExitCode;
11
use Tempest\Console\Middleware\CautionMiddleware;
12
use Tempest\Console\Middleware\ForceMiddleware;
13
use Tempest\Container\Singleton;
14
use Tempest\Database\Migrations\FreshMigrationFailed;
15
use Tempest\Database\Migrations\MigrationManager;
16
use Tempest\Database\Migrations\TableDropped;
17
use Tempest\EventBus\EventHandler;
18

19
#[Singleton]
20
final class MigrateFreshCommand
21
{
22
    private int $count = 0;
23

24
    public function __construct(
67✔
25
        private readonly Console $console,
26
        private readonly MigrationManager $migrationManager,
27
    ) {}
67✔
28

29
    #[ConsoleCommand(
7✔
30
        name: 'migrate:fresh',
31
        description: 'Drops all tables and rerun migrations from scratch',
32
        middleware: [ForceMiddleware::class, CautionMiddleware::class],
33
    )]
34
    public function __invoke(
35
        #[ConsoleArgument(description: 'Validates the integrity of existing migration files by checking if they have been tampered with.')]
36
        bool $validate = true,
37
    ): ExitCode {
38
        if ($validate) {
7✔
39
            $validationSuccess = $this->console->call(MigrateValidateCommand::class);
7✔
40

41
            if ($validationSuccess !== 0 && $validationSuccess !== ExitCode::SUCCESS) {
7✔
42
                return ExitCode::INVALID;
1✔
43
            }
44
        }
45

46
        $this->console->info('Dropping tables…');
7✔
47

48
        $this->migrationManager->dropAll();
7✔
49

50
        $this->console
7✔
51
            ->success(sprintf('Dropped %s tables', $this->count))
7✔
52
            ->writeln();
7✔
53

54
        $this->console->info('Migrate up…');
7✔
55

56
        return $this->console->call(MigrateUpCommand::class);
7✔
57
    }
58

59
    #[EventHandler]
66✔
60
    public function onTableDropped(TableDropped $event): void
61
    {
62
        $this->console->writeln("- Dropped {$event->name}");
66✔
63
        $this->count += 1;
66✔
64
    }
65

UNCOV
66
    #[EventHandler]
×
67
    public function onFreshMigrationFailed(FreshMigrationFailed $event): void
68
    {
UNCOV
69
        $this->console->error($event->throwable->getMessage());
×
70
    }
71
}
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