Ejemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->migrator->setConnection($this->input->getOption('database'));
     $pretend = $this->input->getOption('pretend');
     while ($this->migrator->rollback($this->output, $pretend)) {
     }
 }
 /**
  * Prepare the migration database for running.
  *
  * @return void
  */
 protected function prepareDatabase()
 {
     $this->migrator->setConnection($this->input->getOption('database'));
     if (!$this->migrator->repositoryExists()) {
         $options = ['--database' => $this->input->getOption('database')];
         $this->call('migrate:install', $options);
     }
 }
Ejemplo n.º 3
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->migrator->setConnection($this->input->getOption('database'));
     $package = $this->input->getOption('package') ?: 'application';
     // 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($this->output, $package, $path, $pretend);
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $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);
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->migrator->setConnection($this->option('database'));
     $paths = $this->getMigrationPaths();
     $this->migrator->rollback($paths, ['pretend' => $this->option('pretend'), 'step' => (int) $this->option('step')]);
     foreach ($this->migrator->getNotes() as $note) {
         $this->output->writeln($note);
     }
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->migrator->setConnection($this->option('database'));
     $this->migrator->rollback($this->getMigrationPaths(), ['pretend' => $this->option('pretend'), 'step' => (int) $this->option('step')]);
     // 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);
     }
 }
Ejemplo n.º 7
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $this->migrator->setConnection($this->option('database'));
     if (!$this->migrator->repositoryExists()) {
         return $this->error('No migrations found.');
     }
     $ran = $this->migrator->getRepository()->getRan();
     $migrations = Collection::make($this->getAllMigrationFiles())->map(function ($migration) use($ran) {
         return in_array($this->migrator->getMigrationName($migration), $ran) ? ['<info>Y</info>', $this->migrator->getMigrationName($migration)] : ['<fg=red>N</fg=red>', $this->migrator->getMigrationName($migration)];
     });
     if (count($migrations) > 0) {
         $this->table(['Ran?', 'Migration'], $migrations);
     } else {
         $this->error('No migrations found');
     }
 }
Ejemplo n.º 8
0
 /**
  * Execute the console command.
  */
 public function fire()
 {
     if (!$this->migrator->repositoryExists()) {
         return $this->error('No migrations found.');
     }
     $this->migrator->setConnection($this->input->getOption('database'));
     $ran = $this->migrator->getRepository()->getRan();
     $migrations = [];
     foreach ($this->getAllMigrationFiles() as $migration) {
         $migrations[] = in_array($migration, $ran) ? ['<info>Y</info>', $migration] : ['<fg=red>N</fg=red>', $migration];
     }
     if (count($migrations) > 0) {
         $this->table(['Ran?', 'Migration'], $migrations);
     } else {
         $this->error('No migrations found');
     }
 }
Ejemplo n.º 9
0
 /**
  * Prepare the migration database for running.
  */
 private function prepareDatabase()
 {
     if ($database = $this->getStringOption('database')) {
         $this->migrator->setConnection($database);
     }
     if (!$this->migrator->repositoryExists()) {
         $this->call('migrate:install', ['--database' => $database]);
     }
 }
Ejemplo n.º 10
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->migrator->setConnection($this->input->getOption('database'));
     if (!$this->migrator->repositoryExists()) {
         $this->output->writeln('<comment>Migration table not found.</comment>');
         return;
     }
     $pretend = $this->input->getOption('pretend');
     $this->migrator->reset($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);
     }
 }
Ejemplo n.º 11
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $this->migrator->setConnection($this->option('database'));
     // First, we'll make sure that the migration table actually exists before we
     // start trying to rollback and re-run all of the migrations. If it's not
     // present we will just bail out with a info message for the developer.
     if (!$this->migrator->repositoryExists()) {
         return $this->comment('Migration table not found.');
     }
     $this->migrator->reset($this->getMigrationPaths(), $this->option('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);
     }
 }
Ejemplo n.º 12
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     if (!$this->migrator->repositoryExists()) {
         return $this->error('No migrations found.');
     }
     if (is_null($path = $this->input->getOption('path'))) {
         $path = $this->ask('Please enter the full path of the migration file, without file extension, in the following format: path/migration-file');
     }
     $this->migrator->setConnection($this->input->getOption('database'));
     $path = $this->laravel->basePath() . '/' . $path;
     $ran = $this->migrator->getRepository()->getRan();
     $migrations = [];
     foreach ($this->getAllMigrationFiles($path) as $migration) {
         $migrations[] = in_array($migration, $ran) ? ['<info>Y</info>', $migration] : ['<fg=red>N</fg=red>', $migration];
     }
     if (count($migrations) > 0) {
         $this->table(['Ran?', 'Migration'], $migrations);
     } else {
         $this->error('No migrations found');
     }
 }