Skip to content

Commit

Permalink
Merge pull request #112 from ucan-lab/feature/issue-105
Browse files Browse the repository at this point in the history
windows の場合 migration ファイルの削除がうまくいっていない
  • Loading branch information
ucan-lab authored Mar 28, 2020
2 parents d00f8fa + ee91caa commit 4348ed0
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/Console/DacapoClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace UcanLab\LaravelDacapo\Console;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Console\ConfirmableTrait;
use UcanLab\LaravelDacapo\Storage\MigrationsStorage;

/**
* Class DacapoClearCommand.
Expand Down Expand Up @@ -50,11 +50,28 @@ public function handle(): void
*
* @return void
*/
private function clearMigrationDirectory(): void
protected function clearMigrationDirectory(): void
{
$storage = new MigrationsStorage();
$storage->deleteDirectory();
$storage->makeDirectory();
foreach ($this->getMigrationsFiles() as $filePath) {
unlink($filePath);
}

$this->info('Cleared migration directory.');
}

/**
* @return array
*/
protected function getMigrationsFiles(): array
{
$files = [];

foreach (File::allFiles(database_path('migrations')) as $file) {
if ($file->getExtension() === 'php') {
$files[] = $file->getRealPath();
}
}

return $files;
}
}

0 comments on commit 4348ed0

Please sign in to comment.