Skip to content

Fixed path detection in Rollback, Refresh and Status commands #54

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

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Concerns/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,13 @@ protected function getMigrationPath(): string
{
return $this->laravel->databasePath('actions');
}

protected function getMigrationPaths(): array
{
if ($paths = $this->optionPath()) {
return $paths;
}

return [$this->getMigrationPath()];
}
}
4 changes: 4 additions & 0 deletions src/Concerns/Optionable.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ protected function optionStep(?int $default = null): ?int

protected function optionPath(): ?array
{
if (! $this->hasOption('path')) {
return null;
}

if ($path = $this->option('path')) {
return collect($path)->map(function ($path) {
if ($this->usingRealPath()) {
Expand Down
16 changes: 4 additions & 12 deletions src/Console/Migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,10 @@ public function handle()
protected function prepareDatabase(): void
{
if (! $this->migrator->repositoryExists()) {
$this->call(Names::INSTALL, array_filter([
'--database' => $this->optionDatabase(),
]));
$this->call(Names::INSTALL,
array_filter([
'--database' => $this->optionDatabase(),
]));
}
}

protected function getMigrationPaths(): array
{
if ($paths = $this->optionPath()) {
return $paths;
}

return [$this->getMigrationPath()];
}
}
2 changes: 2 additions & 0 deletions src/Console/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

use DragonCode\LaravelActions\Concerns\Database;
use DragonCode\LaravelActions\Concerns\Infoable;
use DragonCode\LaravelActions\Concerns\Optionable;
use DragonCode\LaravelActions\Constants\Names;
use Illuminate\Database\Console\Migrations\StatusCommand as BaseCommand;

class Status extends BaseCommand
{
use Database;
use Infoable;
use Optionable;

/**
* The console command name.
Expand Down