Completed
Push — master ( 1341d4...acf296 )
by Alejandro
14:18 queued 10:22
created

MigrateDatabaseCommand::getLockConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\CLI\Command\Db;
5
6
use Shlinkio\Shlink\CLI\Command\Util\LockedCommandConfig;
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_HELPER_SCRIPT = 'vendor/doctrine/migrations/bin/doctrine-migrations.php';
16
    public const DOCTRINE_HELPER_COMMAND = 'migrations:migrate';
17
18 5
    protected function configure(): void
19
    {
20
        $this
21 5
            ->setName(self::NAME)
22 5
            ->setDescription('Runs database migrations, which will ensure the shlink database is up to date.');
23
    }
24
25 5
    protected function lockedExecute(InputInterface $input, OutputInterface $output): int
26
    {
27 5
        $io = new SymfonyStyle($input, $output);
28
29 5
        $io->writeln('<fg=blue>Migrating database...</>');
30 5
        $this->runPhpCommand($output, [self::DOCTRINE_HELPER_SCRIPT, self::DOCTRINE_HELPER_COMMAND]);
31 5
        $io->success('Database properly migrated!');
32
33 5
        return ExitCodes::EXIT_SUCCESS;
34
    }
35
36 5
    protected function getLockConfig(): LockedCommandConfig
37
    {
38 5
        return new LockedCommandConfig($this->getName(), true);
39
    }
40
}
41