1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Command; |
4
|
|
|
|
5
|
|
|
use ControleOnline\Service\DatabaseSwitchService; |
6
|
|
|
use Symfony\Component\Console\Attribute\AsCommand; |
|
|
|
|
7
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
8
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
|
|
|
|
9
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
|
|
|
10
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
11
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
|
|
|
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
13
|
|
|
use Symfony\Component\Lock\LockFactory; |
|
|
|
|
14
|
|
|
|
15
|
|
|
#[AsCommand( |
16
|
|
|
name: 'tenant:migrations:migrate', |
17
|
|
|
description: 'Proxy para migrar um novo banco de dados de tenant.', |
18
|
|
|
)] |
19
|
|
|
final class MigrateCommand extends DefaultCommand |
|
|
|
|
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
public function __construct( |
23
|
|
|
LockFactory $lockFactory, |
24
|
|
|
DatabaseSwitchService $databaseSwitchService |
25
|
|
|
) { |
26
|
|
|
$this->lockFactory = $lockFactory; |
|
|
|
|
27
|
|
|
$this->databaseSwitchService = $databaseSwitchService; |
|
|
|
|
28
|
|
|
parent::__construct('tenant:migrations:migrate'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
protected function configure(): void |
32
|
|
|
{ |
33
|
|
|
$this |
34
|
|
|
->setAliases(['t:m:m']) |
35
|
|
|
->setDescription('Proxy para executar doctrine:migrations:migrate para um banco de dados específico.') |
36
|
|
|
->addArgument('version', InputArgument::OPTIONAL, 'O número da versão (AAAAMMDDHHMMSS) ou alias (first, prev, next, latest) para migrar.', 'latest') |
37
|
|
|
->addOption('dry-run', null, InputOption::VALUE_NONE, 'Executar a migração como uma simulação.') |
38
|
|
|
->addOption('query-time', null, InputOption::VALUE_NONE, 'Medir o tempo de todas as consultas individualmente.') |
39
|
|
|
->addOption('allow-no-migration', null, InputOption::VALUE_NONE, 'Não lançar uma exceção quando nenhuma alteração for detectada.'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
protected function runCommand(): int |
43
|
|
|
{ |
44
|
|
|
$newInput = new ArrayInput([ |
45
|
|
|
'version' => $this->input->getArgument('version'), |
46
|
|
|
'--dry-run' => $this->input->getOption('dry-run'), |
47
|
|
|
'--query-time' => $this->input->getOption('query-time'), |
48
|
|
|
'--allow-no-migration' => $this->input->getOption('allow-no-migration'), |
49
|
|
|
]); |
50
|
|
|
$newInput->setInteractive(false); |
51
|
|
|
$command = $this->getApplication()->find('doctrine:migrations:migrate'); |
52
|
|
|
return $command->run($newInput, $this->output); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths