Returns the Version instance for a given version in the format YYYYMMDDHHMMSS.
public getVersion ( string $version ) : |
||
$version | string | The version string in the format YYYYMMDDHHMMSS. |
return |
private function markVersionsMigrated() { foreach ($this->migrations->getAvailableVersions() as $versionIdentifier) { $version = $this->migrations->getVersion($versionIdentifier); $version->markMigrated(); } }
/** * {@inheritdoc} */ public function rollback(EntityManager $em, \appbox $appbox, Configuration $conf) { // truncate created tables $this->emptyTables($em); // rollback schema $this->alterTablesDown($em); $version = $conf->getVersion('20131118000007'); if ($version->isMigrated()) { $version->execute('down'); } $version = $conf->getVersion('20131118000009'); if ($version->isMigrated()) { $version->execute('down'); } }
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(); } } }
/** * Test "--add" option on migrate already migrated version. * * @expectedException InvalidArgumentException * @expectedExceptionMessage The version "1233" already exists in the version table. */ public function testAddOptionIfVersionAlreadyMigrated() { $this->configuration->registerMigration(1233, 'Doctrine\\DBAL\\Migrations\\Tests\\Stub\\Version1Test'); $this->configuration->getVersion('1233')->markMigrated(); $commandTester = new CommandTester($this->command); $commandTester->execute(array('--add' => true, 'version' => 1233), array('interactive' => false)); }
/** * {@inheritdoc} */ public function rollback(EntityManager $em, \appbox $appbox, Configuration $conf) { $this->renameTable($em, 'down'); // truncate created tables $this->emptyTables($em); // rollback schema $this->alterTablesDown($em); $version = $conf->getVersion('ftp-credential'); if ($version->isMigrated()) { $version->execute('down'); } $version = $conf->getVersion('user'); if ($version->isMigrated()) { $version->execute('down'); } }
/** * {@inheritdoc} */ public function getVersion($version) { $version = parent::getVersion($version); $this->container->callInjects($version->getMigration()); return $version; }
public function getVersion($version) { $this->doRegister(); return parent::getVersion($version); }