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

tempestphp / tempest-framework / 14075625373

26 Mar 2025 04:38AM UTC coverage: 79.024% (-0.3%) from 79.311%
14075625373

Pull #1054

github

web-flow
Merge 3c5e5d7a3 into d1704e8de
Pull Request #1054: feat(database): add migration hash checking

17 of 77 new or added lines in 8 files covered. (22.08%)

38 existing lines in 4 files now uncovered.

10522 of 13315 relevant lines covered (79.02%)

90.75 hits per line

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

0.0
/src/Tempest/Framework/Commands/MigrateValidateCommand.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\ConsoleCommand;
9
use Tempest\Console\ExitCode;
10
use Tempest\Container\Singleton;
11
use Tempest\Database\Migrations\MigrationManager;
12
use Tempest\Database\Migrations\MigrationValidationFailed;
13
use Tempest\EventBus\EventHandler;
14

15
#[Singleton]
16
final class MigrateValidateCommand
17
{
18
    private bool $validationPassed = true;
19

NEW
20
    public function __construct(
×
21
        private readonly Console $console,
22
        private readonly MigrationManager $migrationManager,
NEW
23
    ) {}
×
24

NEW
25
    #[ConsoleCommand(
×
26
        name: 'migrate:validate',
27
        description: 'Validates the integrity of existing migration files by checking if they have been tampered with.',
28
    )]
29
    public function __invoke(): ExitCode
30
    {
NEW
31
        $this->console->info('Validating migration files...');
×
32

NEW
33
        $this->migrationManager->validate();
×
34

NEW
35
        if (! $this->validationPassed) {
×
NEW
36
            return ExitCode::ERROR;
×
37
        }
38

NEW
39
        $this->console
×
NEW
40
            ->success('Migration files are valid')
×
NEW
41
            ->writeln();
×
42

NEW
43
        return ExitCode::SUCCESS;
×
44
    }
45

NEW
46
    #[EventHandler]
×
47
    public function onMigrationValidationFailed(MigrationValidationFailed $event): void
48
    {
NEW
49
        $this->console->error(
×
NEW
50
            "Migration file '{$event->name}' failed validation: {$event->exception->getMessage()}",
×
NEW
51
        );
×
52

NEW
53
        $this->validationPassed = false;
×
54
    }
55
}
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