From 4c14c9e94a3f292d18e1e02cd5ec55866338426f Mon Sep 17 00:00:00 2001 From: Yoram Date: Wed, 23 Dec 2020 07:49:11 +0100 Subject: [PATCH 1/3] Added support for migrating single file Laravel framework supports this and I have some situations I need to migrate only a single file instead of all migrations within the migrations folder. This can particularly when you have migrations within your build (phar) and migrations outside of the build. --- src/Components/Database/Migrator.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Components/Database/Migrator.php b/src/Components/Database/Migrator.php index 8b035786..1fd3a250 100644 --- a/src/Components/Database/Migrator.php +++ b/src/Components/Database/Migrator.php @@ -14,6 +14,7 @@ namespace LaravelZero\Framework\Components\Database; use function collect; +use Illuminate\Support\Str; use Illuminate\Database\Migrations\Migrator as BaseMigrator; use SplFileInfo; use Symfony\Component\Finder\Finder; @@ -35,10 +36,17 @@ public function getMigrationFiles($paths): array return collect($paths) ->flatMap( function ($path) { - return collect( - (new Finder)->in([$path]) + $finder = null; + if (Str::endsWith($path, '.php')) { + $finder = (new Finder)->in([dirname($path)]) ->files() - ) + ->name(basename($path)); + } else { + $finder = (new Finder)->in([$path]) + ->files(); + } + + return collect($finder) ->map( function (SplFileInfo $file) { return $file->getPathname(); From 43d7da41f2a5ba3d2cb4bde690377a1ba17019a3 Mon Sep 17 00:00:00 2001 From: Yoram Date: Wed, 23 Dec 2020 07:53:36 +0100 Subject: [PATCH 2/3] Satisfy styleci --- src/Components/Database/Migrator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Database/Migrator.php b/src/Components/Database/Migrator.php index 1fd3a250..2c94e9ba 100644 --- a/src/Components/Database/Migrator.php +++ b/src/Components/Database/Migrator.php @@ -14,8 +14,8 @@ namespace LaravelZero\Framework\Components\Database; use function collect; -use Illuminate\Support\Str; use Illuminate\Database\Migrations\Migrator as BaseMigrator; +use Illuminate\Support\Str; use SplFileInfo; use Symfony\Component\Finder\Finder; From ac7e98761b5d30530433914453b1a0ec8c8a42f3 Mon Sep 17 00:00:00 2001 From: Yoram Date: Mon, 11 Jan 2021 07:26:56 +0100 Subject: [PATCH 3/3] Minor cleanup --- src/Components/Database/Migrator.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Components/Database/Migrator.php b/src/Components/Database/Migrator.php index 2c94e9ba..43f7f04c 100644 --- a/src/Components/Database/Migrator.php +++ b/src/Components/Database/Migrator.php @@ -36,7 +36,6 @@ public function getMigrationFiles($paths): array return collect($paths) ->flatMap( function ($path) { - $finder = null; if (Str::endsWith($path, '.php')) { $finder = (new Finder)->in([dirname($path)]) ->files()