示例#1
0
 /**
  * @param Debugger           $debugger
  * @param ORM                $orm
  * @param ContainerInterface $container
  * @param ClassLocator       $locator
  */
 public function perform(Debugger $debugger, ORM $orm, ContainerInterface $container, ClassLocator $locator)
 {
     //We don't really need location errors here
     $locator->setLogger(new NullLogger());
     $benchmark = $debugger->benchmark($this, 'update');
     $builder = $orm->schemaBuilder($locator);
     //To make builder available for other commands (in sequence)
     $container->bind(get_class($builder), $builder);
     if (!$this->option('sync')) {
         $this->writeln("<comment>Silent mode on, no databases to be altered.</comment>");
     }
     $orm->updateSchema($builder, $this->option('sync'));
     $elapsed = number_format($debugger->benchmark($this, $benchmark), 3);
     $countModels = count($builder->getRecords());
     $this->write("<info>ORM Schema has been updated: <comment>{$elapsed} s</comment>");
     $this->writeln(", found records: <comment>{$countModels}</comment></info>");
 }