Doctrine\DBAL\Migrations\Configuration\Configuration::hasVersion PHP Method

hasVersion() public method

Check if a version exists.
public hasVersion ( string $version ) : boolean
$version string
return boolean
    public function hasVersion($version)
    {
        if (empty($this->migrations)) {
            $this->registerMigrationsFromDirectory($this->getMigrationsDirectory());
        }
        return isset($this->migrations[$version]);
    }

Usage Example

 private function mark($version, $all = false)
 {
     if (!$this->configuration->hasVersion($version)) {
         throw MigrationException::unknownMigrationVersion($version);
     }
     $version = $this->configuration->getVersion($version);
     if ($this->markMigrated && $this->configuration->hasVersionMigrated($version)) {
         $marked = true;
         if (!$all) {
             throw new \InvalidArgumentException(sprintf('The version "%s" already exists in the version table.', $version));
         }
     }
     if (!$this->markMigrated && !$this->configuration->hasVersionMigrated($version)) {
         $marked = false;
         if (!$all) {
             throw new \InvalidArgumentException(sprintf('The version "%s" does not exists in the version table.', $version));
         }
     }
     if (!isset($marked)) {
         if ($this->markMigrated) {
             $version->markMigrated();
         } else {
             $version->markNotMigrated();
         }
     }
 }
All Usage Examples Of Doctrine\DBAL\Migrations\Configuration\Configuration::hasVersion