1 | <?php |
||
14 | class FileDateMigrator implements Migrator |
||
15 | { |
||
16 | use Filesystem; |
||
17 | |||
18 | /** |
||
19 | * Yarak config. |
||
20 | * |
||
21 | * @var Config |
||
22 | */ |
||
23 | protected $config; |
||
24 | |||
25 | /** |
||
26 | * Database connection resolver. |
||
27 | * |
||
28 | * @var ConnectionResolver |
||
29 | */ |
||
30 | protected $resolver; |
||
31 | |||
32 | /** |
||
33 | * Repository for logging migration activity. |
||
34 | * |
||
35 | * @var MigrationRepository |
||
36 | */ |
||
37 | protected $repository; |
||
38 | |||
39 | /** |
||
40 | * The active database connection. |
||
41 | * |
||
42 | * @var \Phalcon\Db\Adapter\Pdo |
||
43 | */ |
||
44 | protected $connection = null; |
||
45 | |||
46 | /** |
||
47 | * Output strategy. |
||
48 | * |
||
49 | * @var Output |
||
50 | */ |
||
51 | protected $output; |
||
52 | |||
53 | /** |
||
54 | * Construct. |
||
55 | * |
||
56 | * @param ConnectionResolver $resolver |
||
57 | * @param MigrationRepository $repository |
||
58 | * @param Output $output |
||
59 | */ |
||
60 | public function __construct( |
||
71 | |||
72 | /** |
||
73 | * Run migrations. |
||
74 | * |
||
75 | * @return array |
||
76 | */ |
||
77 | public function run() |
||
85 | |||
86 | /** |
||
87 | * Get all migration filenames that have not been run. |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | protected function getPendingMigrations() |
||
98 | |||
99 | /** |
||
100 | * Get array of migration file names from directory listed in config. |
||
101 | * |
||
102 | * @return array |
||
103 | */ |
||
104 | protected function getMigrationFiles() |
||
118 | |||
119 | /** |
||
120 | * Run pending migrations. |
||
121 | * |
||
122 | * @param array $migrations |
||
123 | * |
||
124 | * @return array |
||
125 | */ |
||
126 | protected function runPending(array $migrations) |
||
146 | |||
147 | /** |
||
148 | * Run the migration. |
||
149 | * |
||
150 | * @param string $migration |
||
151 | * @param int $batch |
||
152 | */ |
||
153 | protected function runUp($migration, $batch) |
||
161 | |||
162 | /** |
||
163 | * Perform a migration run operation. |
||
164 | * |
||
165 | * @param string $migration |
||
166 | * @param string $method |
||
167 | * |
||
168 | * @return bool |
||
169 | */ |
||
170 | protected function performRun($migration, $method) |
||
184 | |||
185 | /** |
||
186 | * Resolve the migration class from the file name. |
||
187 | * |
||
188 | * @param string $migration |
||
189 | * |
||
190 | * @throws FileNotFound |
||
191 | * |
||
192 | * @return Yarak\Migrations\Migration |
||
193 | */ |
||
194 | protected function resolveMigrationClass($migration) |
||
208 | |||
209 | /** |
||
210 | * Rollback migrations. |
||
211 | * |
||
212 | * @param int $steps |
||
213 | * |
||
214 | * @return array |
||
215 | */ |
||
216 | public function rollback($steps = 1) |
||
224 | |||
225 | /** |
||
226 | * Rollback given migrations. |
||
227 | * |
||
228 | * @param array $migrations |
||
229 | * |
||
230 | * @return array |
||
231 | */ |
||
232 | protected function runRollback(array $migrations) |
||
250 | |||
251 | /** |
||
252 | * Rollback the migration. |
||
253 | * |
||
254 | * @param string $migration |
||
255 | */ |
||
256 | protected function runDown($migration) |
||
264 | |||
265 | /** |
||
266 | * Reset the database by rolling back all migrations. |
||
267 | * |
||
268 | * @return array |
||
269 | */ |
||
270 | public function reset() |
||
278 | |||
279 | /** |
||
280 | * Reset the database and run all migrations. |
||
281 | * |
||
282 | * @return array |
||
283 | */ |
||
284 | public function refresh() |
||
296 | |||
297 | /** |
||
298 | * Perform setup procedures for migrations. |
||
299 | */ |
||
300 | protected function setUp() |
||
310 | |||
311 | /** |
||
312 | * Set connection to database on object. |
||
313 | * |
||
314 | * @return $this |
||
315 | */ |
||
316 | public function setConnection() |
||
326 | |||
327 | /** |
||
328 | * Return the connection. |
||
329 | * |
||
330 | * @return \Phalcon\Db\Adapter\Pdo |
||
331 | */ |
||
332 | public function getConnection() |
||
336 | |||
337 | /** |
||
338 | * Create the migrations table if it doesn't exist. |
||
339 | */ |
||
340 | protected function createMigrationsRepository() |
||
348 | } |
||
349 |