/**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     // Reset a specific addon(s).
     if ($addon = $this->input->getOption('addon')) {
         $pretend = $this->input->getOption('pretend');
         $namespaces = explode(',', $addon);
         foreach ($namespaces as $namespace) {
             while (true) {
                 $count = $this->migrator->rollbackNamespace($namespace, $pretend);
                 // Once the migrator has run we will grab the note output and send it out to
                 // the console screen, since the migrator itself functions without having
                 // any instances of the OutputInterface contract passed into the class.
                 foreach ($this->migrator->getNotes() as $note) {
                     $this->output->writeln($note);
                 }
                 if ($count == 0) {
                     break;
                 }
             }
         }
     } else {
         // Reset everything.
         parent::fire();
     }
     $this->dispatch(new CleanupStreams());
 }
 /**
  * Handle the command.
  */
 public function handle()
 {
     if (!($addon = $this->input->getOption('addon'))) {
         return;
     }
     if (!($addon = $this->dispatch(new GetAddon($addon)))) {
         throw new \Exception("Addon could not be found.");
     }
     $this->migrator->setAddon($addon);
     $this->input->setOption('path', $addon->getAppPath('migrations'));
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->input->getOption('no-addons') && !$this->input->getOption('path')) {
         $this->prepareDatabase();
         $addons = app('Anomaly\\Streams\\Platform\\Addon\\AddonCollection');
         if ($namespaces = $this->input->getOption('addon')) {
             $namespaces = explode(',', $namespaces);
             $addons = $addons->filter(function (Addon $addon) use($namespaces) {
                 return in_array($addon->getNamespace(), $namespaces) || in_array($addon->getSlug(), $namespaces);
             });
         }
         // The pretend option can be used for "simulating" the migration and grabbing
         // the SQL queries that would fire if the migration were to be run against
         // a database for real, which is helpful for double checking migrations.
         $pretend = $this->input->getOption('pretend');
         /** @var Addon $addon */
         foreach ($addons as $addon) {
             $this->migrator->setNamespace($addon->getNamespace())->run($addon->getPath('migrations'), $pretend);
             // Finally, if the "seed" option has been given, we will re-run the database
             // seed task to re-populate the database, which is convenient when adding
             // a migration and a seed at the same time, as it is only this command.
             if ($this->input->getOption('seed')) {
                 $this->call('db:seed', ['--addon' => $addon->getNamespace(), '--force' => true]);
             }
             // Once the migrator has run we will grab the note output and send it out to
             // the console screen, since the migrator itself functions without having
             // any instances of the OutputInterface contract passed into the class.
             foreach ($this->migrator->getNotes() as $note) {
                 $this->output->writeln($note);
             }
         }
     } else {
         $this->migrator->setNamespace('laravel');
         parent::fire();
     }
 }