Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added support for migrating single file #427

Merged
merged 3 commits into from Jan 11, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Components/Database/Migrator.php
Expand Up @@ -15,6 +15,7 @@

use function collect;
use Illuminate\Database\Migrations\Migrator as BaseMigrator;
use Illuminate\Support\Str;
use SplFileInfo;
use Symfony\Component\Finder\Finder;

Expand All @@ -35,10 +36,17 @@ public function getMigrationFiles($paths): array
return collect($paths)
->flatMap(
function ($path) {
return collect(
(new Finder)->in([$path])
$finder = null;
owenvoke marked this conversation as resolved.
Show resolved Hide resolved
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();
Expand Down