diff --git a/src/Console/RollbackMissingMigrations.php b/src/Console/RollbackMissingMigrations.php index b49a458..ff0bc6e 100644 --- a/src/Console/RollbackMissingMigrations.php +++ b/src/Console/RollbackMissingMigrations.php @@ -59,7 +59,8 @@ protected function getMigrationsNamesForRollback(): array protected function rollback(string $artisanPath): void { - $command = sprintf('php %s migrate:rollback %s %s', + $command = sprintf( + 'php %s migrate:rollback %s %s', $artisanPath, $this->getOldPaths(), $this->getRealpath() diff --git a/src/Console/RollbackNewMigrations.php b/src/Console/RollbackNewMigrations.php index cb227fb..ad39653 100644 --- a/src/Console/RollbackNewMigrations.php +++ b/src/Console/RollbackNewMigrations.php @@ -14,9 +14,9 @@ class RollbackNewMigrations extends Command { - private const COMMAND = 'git ls-tree --name-only origin/master database/migrations/'; + private const COMMAND_PATTERN = 'git ls-tree --name-only origin/master {git_migrations_path}'; - protected $signature = 'rollback_new_migrations:rollback'; + protected $signature = 'rollback_new_migrations:rollback {--git_migrations_path=}'; protected $description = 'Rollback new migrations (default way for k8s staging)'; public function handle(): void @@ -26,7 +26,10 @@ public function handle(): void return; } - $migrationsFromMaster = collect(explode(PHP_EOL, shell_exec(self::COMMAND))) + $gitMigrationsPath = $this->option('git_migrations_path') ?? 'database/migrations/'; + $gitCommand = str_replace('{git_migrations_path}', $gitMigrationsPath, self::COMMAND_PATTERN); + + $migrationsFromMaster = collect(explode(PHP_EOL, shell_exec($gitCommand))) ->filter() ->map(fn (string $path) => new SplFileInfo(base_path($path))); $migrationsFromCurrent = collect(File::files(base_path('database/migrations')));