Check if a version has been migrated or not yet
public hasVersionMigrated ( |
||
$version | ||
Résultat | boolean |
public function testSkipMigrateUp() { $version = new \Doctrine\DBAL\Migrations\Version($this->config, 1, 'Doctrine\\DBAL\\Migrations\\Tests\\Functional\\MigrationSkipMigration'); $this->assertFalse($this->config->hasVersionMigrated($version)); $version->execute('up'); $schema = $this->connection->getSchemaManager()->createSchema(); $this->assertFalse($schema->hasTable('foo')); $this->assertTrue($this->config->hasVersionMigrated($version)); }
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(); } } }
/** * Check if this version has been migrated or not. * * @return boolean */ public function isMigrated() { return $this->configuration->hasVersionMigrated($this); }