Esempio n. 1
0
 /**
  * Apply changes to the database.  After execution, you can get a count
  * of the applied changes and an array of the change files applied.
  *
  * @return bool
  */
 public function execute()
 {
     $this->changesAppliedCount = 0;
     $this->appliedFilesByChangeset = array();
     /** @var $changeset \Dewdrop\Db\Dbdeploy\Changeset */
     foreach ($this->changesets as $changeset) {
         $this->appliedFilesByChangeset[$changeset->getName()] = array();
         if (null === $this->changeset || $changeset->getName() === $this->changeset) {
             foreach ($changeset->getNewFiles() as $changeNumber => $file) {
                 $startTime = date('Y-m-d G:i:s');
                 $this->cliExec->run($file);
                 $this->changesAppliedCount += 1;
                 $this->appliedFilesByChangeset[$changeset->getName()][] = $file;
                 $this->changelogGateway->logAppliedFile($changeset->getName(), $changeNumber, $file, isset($_SERVER['USER']) ? $_SERVER['USER'] : '******', $startTime, date('Y-m-d G:i:s'));
             }
         }
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Find the changeset to backfill and then backfill the changelog up to
  * maximum revision number.  Note that the start and end times for the
  * log entry will be identical.
  *
  * @throws \Dewdrop\Db\Dbdeploy\Exception
  */
 public function execute()
 {
     $this->appliedFiles = array();
     $this->changesAppliedCount = 0;
     $matchingChangeset = null;
     /* @var $changeset \Dewdrop\Db\Dbdeploy\Changeset */
     foreach ($this->changesets as $changeset) {
         if ($changeset->getName() === $this->changesetName) {
             $matchingChangeset = $changeset;
             break;
         }
     }
     if (null === $matchingChangeset) {
         throw new Exception("No changeset matching {$this->changesetName} found.");
     }
     foreach ($matchingChangeset->getNewFiles() as $changeNumber => $file) {
         if ($changeNumber <= $this->revision) {
             $this->changelogGateway->logAppliedFile($matchingChangeset->getName(), $changeNumber, $file, isset($_SERVER['USER']) ? $_SERVER['USER'] : '******', date('Y-m-d G:i:s'), date('Y-m-d G:i:s'));
             $this->appliedFiles[] = $file;
             $this->changesAppliedCount += 1;
         }
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Check the DB changelog to find the highest revision number that has
  * been applied for this changeset.
  *
  * @return int
  */
 public function getCurrentRevision()
 {
     return $this->changelogGateway->getCurrentRevisionForChangeset($this->name);
 }