@@ -175,9 +175,9 @@ public function progress(string $group = null)
175175 {
176176 throw ConfigException::forDisabledMigrations ();
177177 }
178-
178+
179179 $ this ->ensureTable ();
180-
180+
181181 // Set database group if not null
182182 if (! is_null ($ group ))
183183 {
@@ -192,13 +192,13 @@ public function progress(string $group = null)
192192 {
193193 return true ;
194194 }
195-
195+
196196 // Remove any migrations already in the history
197197 foreach ($ this ->getHistory ($ this ->group ) as $ history )
198198 {
199199 unset($ migrations [$ this ->getObjectUid ($ history )]);
200200 }
201-
201+
202202 // Start a new batch
203203 $ batch = $ this ->getLastBatch () + 1 ;
204204
@@ -212,9 +212,9 @@ public function progress(string $group = null)
212212 // If a migration failed then try to back out what was done
213213 else {
214214 $ this ->regress (-1 );
215-
215+
216216 $ message = lang ('Migrations.generalFault ' );
217-
217+
218218 if ($ this ->silent )
219219 {
220220 $ this ->cliMessages [] = "\t" . CLI ::color ($ message , 'red ' );
@@ -223,7 +223,7 @@ public function progress(string $group = null)
223223 throw new \RuntimeException ($ message );
224224 }
225225 }
226-
226+
227227 return true ;
228228 }
229229
@@ -246,15 +246,15 @@ public function regress(int $targetBatch, string $group = null)
246246 {
247247 throw ConfigException::forDisabledMigrations ();
248248 }
249-
249+
250250 // Set database group if not null
251251 if (! is_null ($ group ))
252252 {
253253 $ this ->setGroup ($ group );
254254 }
255255
256256 $ this ->ensureTable ();
257-
257+
258258 // Get all the batches
259259 $ batches = $ this ->getBatches ();
260260
@@ -263,7 +263,7 @@ public function regress(int $targetBatch, string $group = null)
263263 {
264264 $ targetBatch = $ batches [count ($ batches ) - 1 + $ targetBatch ] ?? 0 ;
265265 }
266-
266+
267267 // If the goal was rollback then check if it is done
268268 if (empty ($ batches ) && $ targetBatch === 0 )
269269 {
@@ -274,19 +274,19 @@ public function regress(int $targetBatch, string $group = null)
274274 if ($ targetBatch !== 0 && ! in_array ($ targetBatch , $ batches ))
275275 {
276276 $ message = lang ('Migrations.batchNotFound ' ) . $ targetBatch ;
277-
277+
278278 if ($ this ->silent )
279279 {
280280 $ this ->cliMessages [] = "\t" . CLI ::color ($ message , 'red ' );
281281 return false ;
282282 }
283283 throw new \RuntimeException ($ message );
284284 }
285-
285+
286286 // Get all migrations
287287 $ this ->namespace = null ;
288288 $ allMigrations = $ this ->findMigrations ();
289-
289+
290290 // Gather migrations down through each batch until reaching the target
291291 $ migrations = [];
292292 while ($ batch = array_pop ($ batches ))
@@ -302,20 +302,20 @@ public function regress(int $targetBatch, string $group = null)
302302 {
303303 // Create a UID from the history to match its migration
304304 $ uid = $ this ->getObjectUid ($ history );
305-
305+
306306 // Make sure the migration is still available
307307 if (! isset ($ allMigrations [$ uid ]))
308308 {
309309 $ message = lang ('Migrations.gap ' ) . ' ' . $ history ->version ;
310-
310+
311311 if ($ this ->silent )
312312 {
313313 $ this ->cliMessages [] = "\t" . CLI ::color ($ message , 'red ' );
314314 return false ;
315315 }
316316 throw new \RuntimeException ($ message );
317317 }
318-
318+
319319 // Add the history and put it on the list
320320 $ migration = $ allMigrations [$ uid ];
321321 $ migration ->history = $ history ;
@@ -333,7 +333,7 @@ public function regress(int $targetBatch, string $group = null)
333333 // If a migration failed then quit so as not to ruin the whole batch
334334 else {
335335 $ message = lang ('Migrations.generalFault ' );
336-
336+
337337 if ($ this ->silent )
338338 {
339339 $ this ->cliMessages [] = "\t" . CLI ::color ($ message , 'red ' );
@@ -342,7 +342,7 @@ public function regress(int $targetBatch, string $group = null)
342342 throw new \RuntimeException ($ message );
343343 }
344344 }
345-
345+
346346 return true ;
347347 }
348348
@@ -364,9 +364,9 @@ public function force(string $path, string $namespace, string $group = null)
364364 {
365365 throw ConfigException::forDisabledMigrations ();
366366 }
367-
367+
368368 $ this ->ensureTable ();
369-
369+
370370 // Set database group if not null
371371 if (! is_null ($ group ))
372372 {
@@ -378,15 +378,15 @@ public function force(string $path, string $namespace, string $group = null)
378378 if (empty ($ migration ))
379379 {
380380 $ message = lang ('Migrations.notFound ' );
381-
381+
382382 if ($ this ->silent )
383383 {
384384 $ this ->cliMessages [] = "\t" . CLI ::color ($ message , 'red ' );
385385 return false ;
386386 }
387387 throw new \RuntimeException ($ message );
388388 }
389-
389+
390390 // Check the history for a match
391391 $ method = 'up ' ;
392392 $ this ->setNamespace ($ migration ->namespace );
@@ -399,7 +399,7 @@ public function force(string $path, string $namespace, string $group = null)
399399 break ;
400400 }
401401 }
402-
402+
403403 // up
404404 if ($ method == 'up ' )
405405 {
@@ -412,14 +412,14 @@ public function force(string $path, string $namespace, string $group = null)
412412 return true ;
413413 }
414414 }
415-
416- // down
415+
416+ // down
417417 elseif ($ this ->migrate ('down ' , $ migration ))
418418 {
419419 $ this ->removeHistory ($ migration ->history );
420420 return true ;
421421 }
422-
422+
423423 // If it came this far the migration failed
424424 $ message = lang ('Migrations.generalFault ' );
425425
@@ -452,10 +452,10 @@ public function findMigrations(): array
452452 $ migrations [$ migration ->uid ] = $ migration ;
453453 }
454454 }
455-
455+
456456 // Sort migrations ascending by their UID (version)
457457 ksort ($ migrations );
458-
458+
459459 return $ migrations ;
460460 }
461461
@@ -492,7 +492,7 @@ public function findNamespaceMigrations(string $namespace): array
492492 {
493493 // Clean up the file path
494494 $ file = empty ($ this ->path ) ? $ file : $ this ->path . str_replace ($ this ->path , '' , $ file );
495-
495+
496496 // Create the migration object from the file and save it
497497 if ($ migration = $ this ->migrationFromFile ($ file , $ namespace ))
498498 {
@@ -530,7 +530,7 @@ protected function migrationFromFile(string $path, string $namespace)
530530 }
531531
532532 $ locator = Services::locator (true );
533-
533+
534534 // Create migration object using stdClass
535535 $ migration = new \stdClass ();
536536
@@ -562,22 +562,6 @@ public function setNamespace(?string $namespace)
562562 return $ this ;
563563 }
564564
565- /**
566- * Sets the path to the base directory that will be used
567- * when locating migrations. If left null, the value will
568- * be chosen from $this->namespace's directory.
569- *
570- * @param string|null $path
571- *
572- * @return $this
573- */
574- public function setPath (string $ path = null )
575- {
576- $ this ->path = $ path ;
577-
578- return $ this ;
579- }
580-
581565 //--------------------------------------------------------------------
582566
583567 /**
@@ -698,7 +682,7 @@ public function getCliMessages(): array
698682 public function clearCliMessages ()
699683 {
700684 $ this ->cliMessages = [];
701-
685+
702686 return $ this ;
703687 }
704688
@@ -717,7 +701,7 @@ public function clearHistory()
717701 ->truncate ();
718702 }
719703 }
720-
704+
721705 //--------------------------------------------------------------------
722706
723707 /**
@@ -758,16 +742,16 @@ protected function addHistory($migration, int $batch)
758742 */
759743 protected function removeHistory ($ history )
760744 {
761-
745+
762746 $ this ->db ->table ($ this ->table )->where ('id ' , $ history ->id )->delete ();
763-
747+
764748 if (is_cli ())
765749 {
766750 $ this ->cliMessages [] = "\t" . CLI ::color (lang ('Migrations.removed ' ),
767751 'yellow ' ) . "( $ history ->namespace ) " . $ history ->version . '_ ' . $ this ->getMigrationName ($ history ->class );
768752 }
769753 }
770-
754+
771755 //--------------------------------------------------------------------
772756
773757 /**
@@ -780,15 +764,15 @@ protected function removeHistory($history)
780764 public function getHistory (string $ group = 'default ' ): array
781765 {
782766 $ this ->ensureTable ();
783-
767+
784768 $ criteria = ['group ' => $ group ];
785-
769+
786770 // If a namespace was specified then use it
787771 if ($ this ->namespace )
788772 {
789773 $ criteria ['namespace ' ] = $ this ->namespace ;
790774 }
791-
775+
792776 $ query = $ this ->db ->table ($ this ->table )
793777 ->where ($ criteria )
794778 ->orderBy ('id ' , 'ASC ' )
@@ -809,7 +793,7 @@ public function getHistory(string $group = 'default'): array
809793 public function getBatchHistory (int $ batch ): array
810794 {
811795 $ this ->ensureTable ();
812-
796+
813797 $ query = $ this ->db ->table ($ this ->table )
814798 ->where ('batch ' , $ batch )
815799 ->orderBy ('id ' , 'asc ' )
@@ -880,7 +864,7 @@ public function getBatchStart(int $batch): string
880864 $ batches = $ this ->getBatches ();
881865 $ batch = $ batches [count ($ batches ) - 1 + $ targetBatch ] ?? 0 ;
882866 }
883-
867+
884868 $ migration = $ this ->db ->table ($ this ->table )
885869 ->where ('batch ' , $ batch )
886870 ->orderBy ('id ' , 'asc ' )
@@ -909,7 +893,7 @@ public function getBatchEnd(int $batch): string
909893 $ batches = $ this ->getBatches ();
910894 $ batch = $ batches [count ($ batches ) - 1 + $ targetBatch ] ?? 0 ;
911895 }
912-
896+
913897 $ migration = $ this ->db ->table ($ this ->table )
914898 ->where ('batch ' , $ batch )
915899 ->orderBy ('id ' , 'desc ' )
@@ -999,7 +983,7 @@ protected function migrate($direction, $migration): bool
999983 if (! class_exists ($ class , false ))
1000984 {
1001985 $ message = sprintf (lang ('Migrations.classNotFound ' ), $ class );
1002-
986+
1003987 if ($ this ->silent )
1004988 {
1005989 $ this ->cliMessages [] = "\t" . CLI ::color ($ message , 'red ' );
@@ -1014,7 +998,7 @@ protected function migrate($direction, $migration): bool
1014998 if (! is_callable ([$ instance , $ direction ]))
1015999 {
10161000 $ message = sprintf (lang ('Migrations.missingMethod ' ), $ direction );
1017-
1001+
10181002 if ($ this ->silent )
10191003 {
10201004 $ this ->cliMessages [] = "\t" . CLI ::color ($ message , 'red ' );
0 commit comments