コード例 #1
0
 /**
  * Execute the console command.
  *
  * @param ConfigurationProvider $provider
  * @param Migrator              $migrator
  *
  * @throws \Doctrine\DBAL\Migrations\MigrationException
  * @return int
  */
 public function fire(ConfigurationProvider $provider, Migrator $migrator)
 {
     if (!$this->confirmToProceed()) {
         return;
     }
     $configuration = $provider->getForConnection($this->option('connection') ?: null);
     try {
         $migration = new Migration($configuration, $this->argument('version'));
     } catch (ExecutedUnavailableMigrationsException $e) {
         $this->handleExecutedUnavailableMigrationsException($e, $configuration);
     } catch (MigrationVersionException $e) {
         $this->error($e->getMessage());
     }
     if ($path = $this->option('write-sql')) {
         $migrator->migrateToFile($migration, $path);
     } else {
         $migrator->migrate($migration, $this->option('dry-run') ? true : false, $this->option('query-time') ? true : false);
     }
     foreach ($migrator->getNotes() as $note) {
         $this->line($note);
     }
 }