Skip to content

Commit a116621

Browse files
committed
🔧 modify output of migration console
Signed-off-by: otengkwame <[email protected]>
1 parent e5fafef commit a116621

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

Core/controllers/commands/Migration.php

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private function connectDB()
123123
private function migrationRequirements()
124124
{
125125
if (!self::ENABLED) {
126-
echo $this->error("Migrations is currently disabled, please enable it to continue...");
126+
echo $this->error("\tMigrations is currently disabled, please enable it to continue...");
127127
exit;
128128
}
129129

@@ -312,7 +312,8 @@ public function useDB($database = 'default')
312312
*
313313
* @return void
314314
*/
315-
public function index() {
315+
public function index()
316+
{
316317
$this->run();
317318
}
318319

@@ -322,7 +323,8 @@ public function index() {
322323
* @param integer $step
323324
* @return void
324325
*/
325-
public function run($step = 0) {
326+
public function run($step = 0)
327+
{
326328

327329
$lastMigrationFile = array_search($this->previousMigration, $this->migrationFiles);
328330

@@ -335,7 +337,7 @@ public function run($step = 0) {
335337
}
336338

337339
if (!$this->migrationFiles) {
338-
echo $this->error("No Migration File Available To Run");
340+
echo $this->error("\n\tNo Migration File Available To Run\n");
339341
exit;
340342
}
341343

@@ -353,13 +355,13 @@ public function run($step = 0) {
353355

354356
foreach ($this->migrationFiles as $count => $file) {
355357

356-
echo $this->info("Processing $file");
358+
echo $this->info("\tProcessing $file");
357359

358360
$this->prepareUpMigration($file);
359361

360362
$this->db->insert(self::TABLE, ['migration' => $file, 'batch' => $batch]);
361363

362-
echo $this->success("$file done".PHP_EOL);
364+
echo $this->success("\t$file done".PHP_EOL);
363365

364366
if ($step && ($count + 1) >= $step) {
365367
break;
@@ -369,7 +371,7 @@ public function run($step = 0) {
369371

370372
$elapsedTime = round(microtime(true) - $startTime, 3) * 1000;
371373

372-
echo $this->warning("Took $elapsedTime ms to run migrations", 1);
374+
echo $this->warning("\tTook $elapsedTime ms to run migrations", 1);
373375

374376
} catch (\Exception $e) {
375377
exit("Error: ".$e->getMessage().PHP_EOL);
@@ -661,7 +663,7 @@ public function dumpDb($name = null)
661663
public function truncate($database = '')
662664
{
663665
$this->db->truncate(self::TABLE);
664-
echo $this->success("Migration table truncated successfully");
666+
echo $this->success("\n\tMigration table truncated successfully\n");
665667
}
666668

667669
/**
@@ -672,15 +674,15 @@ public function truncate($database = '')
672674
public function reset()
673675
{
674676
if ($this->previousMigration == null) {
675-
echo $this->warning('No Migrations To Reset');
677+
echo $this->warning("\n\tNo Migrations To Reset\n");
676678
exit;
677679
}
678680

679681
if ($this->previousMigration) {
680682
$this->rollback(INF); // infinity
681683
}
682684

683-
echo $this->warning("Migration has been reset to initial state successfully");
685+
echo $this->warning("\n\tMigration has been reset to initial state successfully\n");
684686
}
685687

686688
/**
@@ -694,7 +696,7 @@ public function rollback($step = 0)
694696
$previousMigrations = $this->executedMigrations();
695697

696698
if (!$previousMigrations) {
697-
echo $this->warning("No Migrations To Rollback");
699+
echo $this->warning("\n\tNo Migrations To Rollback\n");
698700
exit;
699701
}
700702

@@ -710,13 +712,13 @@ public function rollback($step = 0)
710712

711713
if ($exists) {
712714

713-
echo $this->info("Rolling back $file");
715+
echo $this->info("\n\tRolling back $file\n");
714716

715717
$this->prepareDownMigration($file);
716718

717719
$this->db->delete(self::TABLE, ['migration' => $migration->migration]);
718720

719-
echo $this->success("$file done".PHP_EOL);
721+
echo $this->success("\n\t$file done".PHP_EOL);
720722
}
721723

722724
if ($step && ($count + 1) >= $step) {
@@ -726,7 +728,7 @@ public function rollback($step = 0)
726728

727729
$elapsedTime = round(microtime(true) - $startTime, 3) * 1000;
728730

729-
echo $this->warning("Took $elapsedTime ms to rollback migrations");
731+
echo $this->warning("\n\tTook $elapsedTime ms to rollback migrations\n");
730732

731733
} catch (\Exception $e) {
732734
exit("Error: ".$e->getMessage().PHP_EOL);
@@ -738,7 +740,8 @@ public function rollback($step = 0)
738740
*
739741
* @return void
740742
*/
741-
public function status() {
743+
public function status()
744+
{
742745

743746
$list = implode(PHP_EOL, array_map(
744747
function($migration) { return $migration->run_at.' '.$migration->migration; },
@@ -751,10 +754,10 @@ function($migration) { return $migration->run_at.' '.$migration->migration; },
751754

752755
if ($list) {
753756

754-
$output = $this->info("\nMigrations Used", 2);
755-
$output .= $this->warning($list, 2);
757+
$output = $this->info("\n\tMigrations Used", 2);
758+
$output .= $this->warning("$list", 2);
756759
} else {
757-
$output .= $this->warning('No Migrations Staged Yet');
760+
$output .= $this->warning("\n\tNo Migrations Staged Yet\n");
758761
}
759762

760763
echo $output;
@@ -773,18 +776,18 @@ public function latest()
773776

774777
$this->output->set_header('Content-type: text/plain');
775778

776-
if (!$migration) {
777-
echo $output = $this->warning('No Current Migration Available');
778-
exit;
779-
}
779+
if (!$migration) {
780+
echo $output = $this->warning("\n\tNo Current Migration Available\n");
781+
exit;
782+
}
780783

781784
$list = $migration->run_at.' '.$migration->migration;
782785

783-
if ($list) {
784-
$output = $this->info("\nLatest Migration", 2);
785-
$output .= $this->warning($list, 2);
786+
if ($list) {
787+
$output = $this->info("\n\tLatest Migration", 2);
788+
$output .= $this->warning("\t{$list}", 2);
786789
} else {
787-
$output .= $this->warning('No Migrations Staged Yet');
790+
$output .= $this->warning("\n\tNo Migrations Staged Yet\n");
788791
}
789792

790793
echo $output;
@@ -811,10 +814,10 @@ public function future()
811814
$output = '';
812815

813816
if ($this->migrationFiles) {
814-
$output = $this->info("\nAvailable Migrations To Run", 2);
817+
$output = $this->info("\n\tAvailable Migrations To Run", 2);
815818
$output .= $this->warning(implode(PHP_EOL, $this->migrationFiles), 2);
816819
} else {
817-
$output = $this->warning("All Migrations Executed Already");
820+
$output = $this->warning("\n\tAll Migrations Executed Already\n");
818821
}
819822

820823
echo $output;

0 commit comments

Comments
 (0)