Example #1
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->prepareDatabase();
     // 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');
     $path = $this->getMigrationPath();
     $this->migrator->run($path, $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);
     }
     // 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', ['--force' => true]);
     }
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->migrator->setConnection($this->input->getOption('database'));
     $pretend = $this->input->getOption('pretend');
     $this->migrator->rollback($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);
     }
 }
 /**
  * Run migrations for the specified module.
  *
  * @param string $slug
  *
  * @return mixed
  */
 protected function migrate($slug)
 {
     if (!$this->module->exists($slug)) {
         return $this->error('Module does not exist.');
     }
     $pretend = Arr::get($this->option(), 'pretend', false);
     $path = $this->getMigrationPath($slug);
     $this->migrator->run($path, $pretend);
     //
     foreach ($this->migrator->getNotes() as $note) {
         if (!$this->option('quiet')) {
             $this->line($note);
         }
     }
     if ($this->option('seed')) {
         $this->call('module:seed', ['module' => $slug, '--force' => true]);
     }
 }