예제 #1
0
 /**
  * Load all migrations and execute them
  *
  * @param String $scriptPath Path to the script to execute
  *
  * @return void
  */
 protected function runUp($buckets)
 {
     try {
         $log = $this->log();
         $log->info('Start running migrations...');
         foreach ($buckets as $bucket) {
             $this->db->logStart($bucket);
             // Prepare a specific logger that will be used to store all
             // Bucket traces into the database so the buckets and it's logs
             // will be linked
             $log = Logger::getLogger(get_class());
             $log->addAppender($this->dbDriver->getBucketLoggerAppender($bucket));
             $bucket->setLoggerParent($log);
             $log->info("Processing " . get_class($bucket));
             $bucket->preUp();
             $log->info("PreUp OK");
             $bucket->up();
             $log->info("Up OK");
             $bucket->postUp();
             $log->info("PostUp OK");
             $this->db->logEnd($bucket, ForgeUpgrade_Db::STATUS_SUCCESS);
         }
     } catch (Exception $e) {
         // Use the last defined $log (so error messages are attached to the
         // right bucket in DB)
         $log->error($e->getMessage());
         $this->db->logEnd($bucket, ForgeUpgrade_Db::STATUS_FAILURE);
     }
 }
예제 #2
0
 /**
  * It executes the bucket and logs its status 
  * 
  * @param ForgeUpgrade_Bucket  $bucket
  * @param Logger               $log
  */
 public function runUpBucket($bucket, $log)
 {
     $this->db->logStart($bucket);
     // Prepare a specific logger that will be used to store all
     // Bucket traces into the database so the buckets and it's logs
     // will be linked
     $bucketAppender = $this->dbDriver->getBucketLoggerAppender($bucket);
     $log->addAppender($bucketAppender);
     $bucket->setLoggerParent($log);
     $log->info("Processing " . get_class($bucket));
     if (!$this->options['core']['ignore_preup']) {
         $bucket->preUp();
         $log->info("PreUp OK");
     }
     $bucket->up();
     $log->info("Up OK");
     $bucket->postUp();
     $log->info("PostUp OK");
     $this->db->logEnd($bucket, ForgeUpgrade_Db::STATUS_SUCCESS);
     $log->removeAppender($bucketAppender);
 }