Пример #1
0
 /**
  * @return boolean
  * @param string $onlyVersion
  */
 public function run($onlyVersion = null)
 {
     try {
         $this->logAllStart();
         $transaction = false;
         foreach ($this->getSteps() as $name => $step) {
             /* @var $step Nano_Migrate_Step */
             if (Nano_Migrate_Version::exists($this->getDb(), $name)) {
                 continue;
             }
             if (null !== $onlyVersion && $onlyVersion !== $name) {
                 continue;
             }
             $this->logStepStart($name, $step);
             $this->getDb()->beginTransaction();
             $transaction = true;
             $step->run($this->getDb());
             $this->getDb()->commit();
             Nano_Migrate_Version::add($this->getDb(), $name);
             $transaction = false;
             $this->logStepDone($name, $step);
         }
         $this->logAllDone();
     } catch (Exception $e) {
         if (true === $transaction) {
             $this->getDb()->rollBack();
         }
         throw $e;
     }
     return true;
 }