1 | <?php |
||
26 | abstract class AbstractMigration implements MigrationInterface |
||
27 | { |
||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $environment; |
||
32 | |||
33 | /** |
||
34 | * @var int |
||
35 | */ |
||
36 | protected $version; |
||
37 | |||
38 | /** |
||
39 | * @var \Phinx\Db\Adapter\AdapterInterface |
||
40 | */ |
||
41 | protected $adapter; |
||
42 | |||
43 | /** |
||
44 | * @var \Symfony\Component\Console\Output\OutputInterface |
||
45 | */ |
||
46 | protected $output; |
||
47 | |||
48 | /** |
||
49 | * @var \Symfony\Component\Console\Input\InputInterface |
||
50 | */ |
||
51 | protected $input; |
||
52 | |||
53 | /** |
||
54 | * Whether this migration is being applied or reverted |
||
55 | * |
||
56 | * @var bool |
||
57 | */ |
||
58 | protected $isMigratingUp = true; |
||
59 | |||
60 | /** |
||
61 | * List of all the table objects created by this migration |
||
62 | * |
||
63 | * @var array |
||
64 | */ |
||
65 | protected $tables = []; |
||
66 | |||
67 | /** |
||
68 | * @param string $environment Environment Detected |
||
69 | * @param int $version Migration Version |
||
70 | * @param \Symfony\Component\Console\Input\InputInterface|null $input |
||
71 | * @param \Symfony\Component\Console\Output\OutputInterface|null $output |
||
72 | */ |
||
73 | final public function __construct($environment, $version, InputInterface $input = null, OutputInterface $output = null) |
||
86 | 384 | ||
87 | 384 | /** |
|
88 | 406 | * @inheritDoc |
|
89 | 384 | */ |
|
90 | 384 | public function setAdapter(AdapterInterface $adapter) |
|
96 | |||
97 | /** |
||
98 | * @inheritDoc |
||
99 | */ |
||
100 | 406 | public function getAdapter() |
|
104 | |||
105 | /** |
||
106 | * @inheritDoc |
||
107 | 1 | */ |
|
108 | public function setInput(InputInterface $input) |
||
109 | 1 | { |
|
110 | $this->input = $input; |
||
111 | |||
112 | return $this; |
||
113 | } |
||
114 | 1 | ||
115 | /** |
||
116 | 1 | * @inheritDoc |
|
117 | */ |
||
118 | public function getInput() |
||
119 | { |
||
120 | return $this->input; |
||
121 | 21 | } |
|
122 | |||
123 | 21 | /** |
|
124 | 21 | * @inheritDoc |
|
125 | */ |
||
126 | public function setOutput(OutputInterface $output) |
||
132 | 13 | ||
133 | /** |
||
134 | * @inheritDoc |
||
135 | */ |
||
136 | public function getOutput() |
||
140 | 384 | ||
141 | 384 | /** |
|
142 | * @inheritDoc |
||
143 | */ |
||
144 | public function getName() |
||
148 | |||
149 | 2 | /** |
|
150 | * @inheritDoc |
||
151 | */ |
||
152 | public function getEnvironment() |
||
156 | |||
157 | 385 | /** |
|
158 | 385 | * @inheritDoc |
|
159 | */ |
||
160 | public function setVersion($version) |
||
166 | 3 | ||
167 | /** |
||
168 | * @inheritDoc |
||
169 | */ |
||
170 | public function getVersion() |
||
174 | 140 | ||
175 | /** |
||
176 | * @inheritDoc |
||
177 | */ |
||
178 | public function setMigratingUp($isMigratingUp) |
||
184 | |||
185 | /** |
||
186 | * @inheritDoc |
||
187 | */ |
||
188 | public function isMigratingUp() |
||
192 | |||
193 | /** |
||
194 | * @inheritDoc |
||
195 | */ |
||
196 | public function execute($sql) |
||
200 | 10 | ||
201 | /** |
||
202 | * @inheritDoc |
||
203 | */ |
||
204 | public function query($sql) |
||
208 | 2 | ||
209 | /** |
||
210 | * @inheritDoc |
||
211 | */ |
||
212 | public function getQueryBuilder() |
||
216 | 3 | ||
217 | /** |
||
218 | * @inheritDoc |
||
219 | */ |
||
220 | public function fetchRow($sql) |
||
224 | 1 | ||
225 | /** |
||
226 | * @inheritDoc |
||
227 | */ |
||
228 | public function fetchAll($sql) |
||
232 | 1 | ||
233 | /** |
||
234 | * @inheritDoc |
||
235 | */ |
||
236 | public function insert($table, $data) |
||
237 | { |
||
238 | 1 | trigger_error('insert() is deprecated since 0.10.0. Use $this->table($tableName)->insert($data)->save() instead.', E_USER_DEPRECATED); |
|
239 | // convert to table object |
||
240 | 1 | if (is_string($table)) { |
|
241 | $table = new Table($table, [], $this->getAdapter()); |
||
242 | } |
||
243 | $table->insert($data)->save(); |
||
244 | } |
||
245 | |||
246 | 3 | /** |
|
247 | * @inheritDoc |
||
248 | */ |
||
249 | 3 | public function createDatabase($name, $options) |
|
253 | 3 | ||
254 | /** |
||
255 | * @inheritDoc |
||
256 | */ |
||
257 | public function dropDatabase($name) |
||
261 | 1 | ||
262 | /** |
||
263 | * @inheritDoc |
||
264 | */ |
||
265 | public function hasTable($tableName) |
||
269 | 1 | ||
270 | /** |
||
271 | * @inheritDoc |
||
272 | */ |
||
273 | public function table($tableName, $options = []) |
||
280 | |||
281 | /** |
||
282 | 5 | * A short-hand method to drop the given database table. |
|
283 | * |
||
284 | 5 | * @deprecated since 0.10.0. Use $this->table($tableName)->drop()->save() instead. |
|
285 | * |
||
286 | * @param string $tableName Table Name |
||
287 | * |
||
288 | * @return void |
||
289 | */ |
||
290 | public function dropTable($tableName) |
||
295 | 1 | ||
296 | 1 | /** |
|
297 | * Perform checks on the migration, print a warning |
||
298 | * if there are potential problems. |
||
299 | * |
||
300 | * Right now, the only check is if there is both a `change()` and |
||
301 | * an `up()` or a `down()` method. |
||
302 | * |
||
303 | * @param string|null $direction |
||
304 | * |
||
305 | * @return void |
||
306 | */ |
||
307 | public function preFlightCheck($direction = null) |
||
319 | |||
320 | /** |
||
321 | * Perform checks on the migration after completion |
||
322 | * |
||
323 | * Right now, the only check is whether all changes were committed |
||
324 | * |
||
325 | * @param string|null $direction direction of migration |
||
326 | * |
||
327 | * @throws \RuntimeException |
||
328 | * |
||
329 | * @return void |
||
330 | */ |
||
331 | public function postFlightCheck($direction = null) |
||
339 | } |
||
340 |