Beispiel #1
0
 /**
  * @return bool
  */
 protected function verifyConfigured()
 {
     if (!$this->migrator->isConfigured()) {
         $this->writeln("<fg=red>Migrations are not configured yet, run '<info>migrate:init</info>' first.</fg=red>");
         return false;
     }
     return true;
 }
 /**
  * @param Migrator $migrator
  * @throws ScaffolderException
  */
 public function perform(Migrator $migrator)
 {
     /**
      * @var MigrationDeclaration $declaration
      */
     $declaration = $this->createDeclaration();
     if (!empty($this->option('table'))) {
         $columns = [];
         foreach ($this->option('column') as $field) {
             if (strpos($field, ':') === false) {
                 throw new ScaffolderException("Column definition must in 'name:type' form.");
             }
             list($name, $type) = explode(':', $field);
             $columns[$name] = $type;
         }
         $declaration->declareCreation($this->option('table'), $columns);
     }
     $file = new FileDeclaration($this->elementNamespace(), $this->config->headerLines());
     $file->addElement($declaration);
     $filename = $migrator->getRepository()->registerMigration($this->argument('name'), $declaration->getName(), $file->render());
     $this->writeln("Declaration of '<info>{$declaration->getName()}</info>' " . "has been successfully written into '<comment>{$filename}</comment>'.");
 }