MigrateMaster.php 885 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use App\Services\MigrationService;
  5. class MigrateMaster extends Command
  6. {
  7. protected $signature = 'migrate:master {--rollback} {--step=1}';
  8. protected $description = 'Run migrations on master database only';
  9. public function handle(MigrationService $migrationService)
  10. {
  11. if ($this->option('rollback')) {
  12. $result = $migrationService->rollbackMasterMigrations($this->option('step'));
  13. $this->info($result['message']);
  14. $this->line($result['output']);
  15. } else {
  16. $result = $migrationService->runMasterMigrations();
  17. $this->info($result['message']);
  18. if (!empty($result['migrations'])) {
  19. $this->table(['Master Migrations'], array_map(fn($m) => [$m], $result['migrations']));
  20. }
  21. }
  22. }
  23. }