MigrateDatabaseCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 12
dl 0
loc 22
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A lockedExecute() 0 9 1
A configure() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\CLI\Command\Db;
6
7
use Shlinkio\Shlink\CLI\Util\ExitCodes;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Symfony\Component\Console\Style\SymfonyStyle;
11
12
class MigrateDatabaseCommand extends AbstractDatabaseCommand
13
{
14
    public const NAME = 'db:migrate';
15
    public const DOCTRINE_MIGRATIONS_SCRIPT = 'vendor/doctrine/migrations/bin/doctrine-migrations.php';
16
    public const DOCTRINE_MIGRATE_COMMAND = 'migrations:migrate';
17
18 1
    protected function configure(): void
19
    {
20
        $this
21 1
            ->setName(self::NAME)
22 1
            ->setDescription('Runs database migrations, which will ensure the shlink database is up to date.');
23 1
    }
24
25 1
    protected function lockedExecute(InputInterface $input, OutputInterface $output): int
26
    {
27 1
        $io = new SymfonyStyle($input, $output);
28
29 1
        $io->writeln('<fg=blue>Migrating database...</>');
30 1
        $this->runPhpCommand($output, [self::DOCTRINE_MIGRATIONS_SCRIPT, self::DOCTRINE_MIGRATE_COMMAND]);
31 1
        $io->success('Database properly migrated!');
32
33 1
        return ExitCodes::EXIT_SUCCESS;
34
    }
35
}
36