Beispiel #1
0
 /**
  * @param MigrationsGenerateCommand $command
  */
 public function migrationsGenerate(MigrationsGenerateCommand $command)
 {
     $latestAvailableVersion = $this->migrator->status()->latestAvailableVersion();
     if ($latestAvailableVersion == null) {
         $latestAvailableVersion = Version::fromString('0.0.0');
     }
     $nextVersion = $latestAvailableVersion;
     if ($command->isMajor()) {
         $nextVersion->increment(VersionIncrementType::MAJOR());
     } else {
         $nextVersion->increment(VersionIncrementType::MINOR());
     }
     $command->getIo()->writeLine('Generating migrations classes for version <c2>' . $nextVersion->__toString() . '</c2>');
     try {
         $this->migrator->generate($nextVersion);
         $command->getIo()->writeLine('The migration has been <c1>successfully generated</c1>');
     } catch (\Exception $e) {
         $command->getIo()->writeLine('<error>' . $e->getMessage() . '</error>');
     }
 }