|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the O2System Framework package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
* |
|
8
|
|
|
* @author Steeve Andrian Salim |
|
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
|
10
|
|
|
*/ |
|
11
|
|
|
// ------------------------------------------------------------------------ |
|
12
|
|
|
|
|
13
|
|
|
namespace O2System\Framework\Cli\Commanders; |
|
14
|
|
|
|
|
15
|
|
|
// ------------------------------------------------------------------------ |
|
16
|
|
|
|
|
17
|
|
|
use O2System\Framework\Cli\Commander; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class Migration |
|
21
|
|
|
* @package O2System\Framework\Cli\Commanders |
|
22
|
|
|
*/ |
|
23
|
|
|
class Migration extends Commander |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* Migration::$commandVersion |
|
27
|
|
|
* |
|
28
|
|
|
* Command version. |
|
29
|
|
|
* |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $commandVersion = '1.0.0'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Migration::$commandDescription |
|
36
|
|
|
* |
|
37
|
|
|
* Command description. |
|
38
|
|
|
* |
|
39
|
|
|
* @var string |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $commandDescription = 'CLI_MIGRATION_DESC'; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Migration::$commandOptions |
|
45
|
|
|
* |
|
46
|
|
|
* Command options. |
|
47
|
|
|
* |
|
48
|
|
|
* @var array |
|
49
|
|
|
*/ |
|
50
|
|
|
protected $commandOptions = [ |
|
51
|
|
|
'version' => [ |
|
52
|
|
|
'description' => 'CLI_MIGRATION_VERSION_HELP', |
|
53
|
|
|
'required' => false, |
|
54
|
|
|
], |
|
55
|
|
|
'reset' => [ |
|
56
|
|
|
'description' => 'CLI_MIGRATION_RESET_HELP', |
|
57
|
|
|
'required' => true, |
|
58
|
|
|
], |
|
59
|
|
|
'rollback' => [ |
|
60
|
|
|
'description' => 'CLI_MIGRATION_ROLLBACK_HELP', |
|
61
|
|
|
'required' => false, |
|
62
|
|
|
], |
|
63
|
|
|
'refresh' => [ |
|
64
|
|
|
'description' => 'CLI_MIGRATION_REFRESH_HELP', |
|
65
|
|
|
'required' => false, |
|
66
|
|
|
], |
|
67
|
|
|
'fresh' => [ |
|
68
|
|
|
'description' => 'CLI_MIGRATION_FRESH_HELP', |
|
69
|
|
|
'required' => false, |
|
70
|
|
|
], |
|
71
|
|
|
'seed' => [ |
|
72
|
|
|
'description' => 'CLI_MIGRATION_SEED_HELP', |
|
73
|
|
|
'required' => false, |
|
74
|
|
|
], |
|
75
|
|
|
]; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Migration::$optionVersion |
|
79
|
|
|
* |
|
80
|
|
|
* @var string |
|
81
|
|
|
*/ |
|
82
|
|
|
protected $optionVersion; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* Migration::$optionReset |
|
86
|
|
|
* |
|
87
|
|
|
* @var bool |
|
88
|
|
|
*/ |
|
89
|
|
|
protected $optionReset = false; |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Migration::$optionRollback |
|
93
|
|
|
* |
|
94
|
|
|
* @var bool |
|
95
|
|
|
*/ |
|
96
|
|
|
protected $optionRollback = false; |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Migration::$optionFresh |
|
100
|
|
|
* |
|
101
|
|
|
* @var bool |
|
102
|
|
|
*/ |
|
103
|
|
|
protected $optionFresh = false; |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Migration::$optionSeed |
|
107
|
|
|
* |
|
108
|
|
|
* @var bool |
|
109
|
|
|
*/ |
|
110
|
|
|
protected $optionSeed = false; |
|
111
|
|
|
|
|
112
|
|
|
// ------------------------------------------------------------------------ |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Migration::optionVersion |
|
116
|
|
|
* |
|
117
|
|
|
* @param string $version |
|
118
|
|
|
*/ |
|
119
|
|
|
public function optionVersion($version) |
|
120
|
|
|
{ |
|
121
|
|
|
$this->optionVersion = $version; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
// ------------------------------------------------------------------------ |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* Migration::optionReset |
|
128
|
|
|
* |
|
129
|
|
|
* @param bool $reset |
|
130
|
|
|
*/ |
|
131
|
|
|
public function optionReset($reset) |
|
132
|
|
|
{ |
|
133
|
|
|
$this->optionReset = (bool)$reset; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
// ------------------------------------------------------------------------ |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* Migration::rollback |
|
140
|
|
|
* |
|
141
|
|
|
* @param bool $rollback |
|
142
|
|
|
*/ |
|
143
|
|
|
public function optionRollback($rollback) |
|
144
|
|
|
{ |
|
145
|
|
|
$this->optionRollback = (bool)$rollback; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
// ------------------------------------------------------------------------ |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* Migration::optionFresh |
|
152
|
|
|
* |
|
153
|
|
|
* @param bool $fresh |
|
154
|
|
|
*/ |
|
155
|
|
|
public function optionFresh($fresh) |
|
156
|
|
|
{ |
|
157
|
|
|
$this->optionFresh = (bool)$fresh; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
// ------------------------------------------------------------------------ |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Migration::execute |
|
164
|
|
|
* |
|
165
|
|
|
* @throws \ReflectionException |
|
166
|
|
|
*/ |
|
167
|
|
|
public function execute() |
|
168
|
|
|
{ |
|
169
|
|
|
$options = input()->get(); |
|
|
|
|
|
|
170
|
|
|
|
|
171
|
|
|
parent::execute(); |
|
172
|
|
|
|
|
173
|
|
|
|
|
174
|
|
|
} |
|
175
|
|
|
} |