Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 2, 2017
1 parent 7c030b3 commit fa9515e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
13 changes: 7 additions & 6 deletions src/Illuminate/Database/Console/Migrations/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ public function handle()
}

$ran = $this->migrator->getRepository()->getRan();
$migrationsBatches = $this->migrator->getRepository()->getMigrationsBatches();

if (count($migrations = $this->getStatusFor($ran, $migrationsBatches)) > 0) {
$batches = $this->migrator->getRepository()->getMigrationBatches();

if (count($migrations = $this->getStatusFor($ran, $batches)) > 0) {
$this->table(['Ran?', 'Migration', 'Batch'], $migrations);
} else {
$this->error('No migrations found');
Expand All @@ -69,17 +70,17 @@ public function handle()
* Get the status for the given ran migrations.
*
* @param array $ran
* @param array $migrationsBatches
* @param array $batches
* @return \Illuminate\Support\Collection
*/
protected function getStatusFor(array $ran, array $migrationsBatches)
protected function getStatusFor(array $ran, array $batches)
{
return Collection::make($this->getAllMigrationFiles())
->map(function ($migration) use ($ran, $migrationsBatches) {
->map(function ($migration) use ($ran, $batches) {
$migrationName = $this->migrator->getMigrationName($migration);

return in_array($migrationName, $ran)
? ['<info>Y</info>', $migrationName, $migrationsBatches[$migrationName]]
? ['<info>Y</info>', $migrationName, $batches[$migrationName]]
: ['<fg=red>N</fg=red>', $migrationName];
});
}
Expand Down
30 changes: 15 additions & 15 deletions src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(Resolver $resolver, $table)
}

/**
* Get the ran migrations.
* Get the completed migrations.
*
* @return array
*/
Expand All @@ -53,19 +53,6 @@ public function getRan()
->pluck('migration')->all();
}

/**
* Get the ran migrations with batch numbers.
*
* @return array
*/
public function getMigrationsBatches()
{
return $this->table()
->orderBy('batch', 'asc')
->orderBy('migration', 'asc')
->pluck('batch', 'migration')->all();
}

/**
* Get list of migrations.
*
Expand Down Expand Up @@ -93,11 +80,24 @@ public function getLast()
return $query->orderBy('migration', 'desc')->get()->all();
}

/**
* Get the completed migrations with their batch numbers.
*
* @return array
*/
public function getMigrationBatches()
{
return $this->table()
->orderBy('batch', 'asc')
->orderBy('migration', 'asc')
->pluck('batch', 'migration')->all();
}

/**
* Log that a migration was run.
*
* @param string $file
* @param int $batch
* @param int $batch
* @return void
*/
public function log($file, $batch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@
interface MigrationRepositoryInterface
{
/**
* Get the ran migrations for a given package.
* Get the completed migrations.
*
* @return array
*/
public function getRan();

/**
* Get the ran migrations with batch numbers for a given package.
*
* @return array
*/
public function getMigrationsBatches();

/**
* Get list of migrations.
*
Expand All @@ -33,11 +26,18 @@ public function getMigrations($steps);
*/
public function getLast();

/**
* Get the completed migrations with their batch numbers.
*
* @return array
*/
public function getMigrationBatches();

/**
* Log that a migration was run.
*
* @param string $file
* @param int $batch
* @param int $batch
* @return void
*/
public function log($file, $batch);
Expand Down

0 comments on commit fa9515e

Please sign in to comment.