|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Created by PhpStorm. |
|
4
|
|
|
* User: joshgulledge |
|
5
|
|
|
* Date: 2/15/18 |
|
6
|
|
|
* Time: 3:23 PM |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace LCI\Blend\Console; |
|
10
|
|
|
|
|
11
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
12
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
13
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
14
|
|
|
|
|
15
|
|
|
class Migrate extends BaseCommand |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @see https://symfony.com/doc/current/console.html |
|
19
|
|
|
* |
|
20
|
|
|
*/ |
|
21
|
|
|
protected function configure() |
|
22
|
|
|
{ |
|
23
|
|
|
$this |
|
24
|
|
|
->setName('blend:migrate') |
|
25
|
|
|
->setDescription('Run Blend Data migrations') |
|
26
|
|
|
->addOption( |
|
27
|
|
|
'name', |
|
28
|
|
|
'N', |
|
29
|
|
|
InputOption::VALUE_OPTIONAL, |
|
30
|
|
|
'The name of the migration file to run. Or when used with the -g option, name the generated migration file' |
|
31
|
|
|
) |
|
32
|
|
|
->addOption( |
|
33
|
|
|
'method', |
|
34
|
|
|
'm', |
|
35
|
|
|
InputOption::VALUE_OPTIONAL, |
|
36
|
|
|
'Up or down(rollback)', |
|
37
|
|
|
'up' |
|
38
|
|
|
) |
|
39
|
|
|
->addOption( |
|
40
|
|
|
'id', |
|
41
|
|
|
'i', |
|
42
|
|
|
InputOption::VALUE_OPTIONAL, |
|
43
|
|
|
'ID of migration to run' |
|
44
|
|
|
) |
|
45
|
|
|
->addOption( |
|
46
|
|
|
'count', |
|
47
|
|
|
'c', |
|
48
|
|
|
InputOption::VALUE_OPTIONAL, |
|
49
|
|
|
'How many to rollback when using the [--method down] option' |
|
50
|
|
|
) |
|
51
|
|
|
->addOption( |
|
52
|
|
|
'type', |
|
53
|
|
|
't', |
|
54
|
|
|
InputOption::VALUE_OPTIONAL, |
|
55
|
|
|
'Server type to run migrations. Possible master, staging, dev and local', |
|
56
|
|
|
'master' |
|
57
|
|
|
) |
|
58
|
|
|
->addOption( |
|
59
|
|
|
'package', |
|
60
|
|
|
'p', |
|
61
|
|
|
InputOption::VALUE_OPTIONAL, |
|
62
|
|
|
'Enter a valid package name, like lci/stockpile', |
|
63
|
|
|
'' |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @param InputInterface $input |
|
69
|
|
|
* @param OutputInterface $output |
|
70
|
|
|
* @return int|null|void |
|
71
|
|
|
* @throws \LCI\Blend\Exception\MigratorException |
|
72
|
|
|
*/ |
|
73
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
74
|
|
|
{ |
|
75
|
|
|
$name = (string)$input->getOption('name'); |
|
76
|
|
|
$type = (string)$input->getOption('type'); |
|
77
|
|
|
$id = $input->getOption('id'); |
|
78
|
|
|
$count = $input->getOption('count'); |
|
79
|
|
|
|
|
80
|
|
|
$method = $input->getOption('method'); |
|
81
|
|
|
$package = $input->getOption('package'); |
|
82
|
|
|
if (!empty($package)) { |
|
83
|
|
|
$this->blender->setProject($package); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
$this->blender->runMigration($method, $type, $count, $id, $name); |
|
|
|
|
|
|
87
|
|
|
} |
|
88
|
|
|
} |