|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Del\Common\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Del\Common\ContainerService; |
|
6
|
|
|
use Doctrine\Migrations\Tools\Console\Command\MigrateCommand; |
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
10
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
11
|
|
|
|
|
12
|
|
|
class Migration extends MigrateCommand |
|
13
|
|
|
{ |
|
14
|
1 |
|
protected function configure(): void |
|
15
|
|
|
{ |
|
16
|
1 |
|
parent::configure(); |
|
17
|
1 |
|
$this->setName('migrant'); |
|
18
|
1 |
|
$this->addArgument('vendor', InputArgument::OPTIONAL, 'The vendor directory containing the migrations.'); |
|
19
|
1 |
|
$this->addOption('configuration', null, InputOption::VALUE_OPTIONAL, 'The path to a migrations configuration file.'); |
|
20
|
1 |
|
$this->addOption('db-configuration', null, InputOption::VALUE_OPTIONAL, 'The path to a database connection configuration file.'); |
|
21
|
1 |
|
} |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param InputInterface $input |
|
26
|
|
|
* @param OutputInterface $output |
|
27
|
|
|
* @return int|null |
|
28
|
|
|
*/ |
|
29
|
|
|
public function execute(InputInterface $input, OutputInterface $output): ?int |
|
30
|
|
|
{ |
|
31
|
|
|
if ($path = $input->getArgument('vendor')) { |
|
32
|
|
|
$path = 'vendor/' . $path . '/migrations'; |
|
33
|
|
|
$config = $this->getMigrationConfiguration($input, $output); |
|
34
|
|
|
$config->setMigrationsDirectory($path); |
|
35
|
|
|
$config->registerMigrationsFromDirectory($path); |
|
36
|
|
|
$this->setMigrationConfiguration($config); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
return parent::execute($input, $output); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|