/** * Load all migrations and execute them * * If force option is set, all buckets will be run even if it fails * Else if not, buckets' execution will drop since one bucket fails * @param String $scriptPath Path to the script to execute * * @return void */ protected function runUp($buckets) { $log = $this->log(); $log->info('Start running migrations...'); // Keep original logger: $log will be modified in runUpBucket in order // to store results in the database attached to the bucket. $origLogger = clone $log; if (!$this->options['core']['force']) { try { foreach ($buckets as $bucket) { $this->runUpBucket($bucket, $log); unset($bucket); } } catch (Exception $e) { $log->error($e->getMessage()); $this->db->logEnd($bucket, ForgeUpgrade_Db::STATUS_FAILURE); } } else { foreach ($buckets as $bucket) { try { $this->runUpBucket($bucket, $log); unset($bucket); } catch (Exception $e) { $log->error($e->getMessage()); $this->db->logEnd($bucket, ForgeUpgrade_Db::STATUS_FAILURE); } } } $log = $origLogger; }
/** * 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); } }