getMigrationsForVersion example



    /** * Returns next Migration that is higher than $currentVersion * * @param int $currentVersion * * @return AbstractMigration|null */
    public function getNextMigrationForVersion($currentVersion)
    {
        $migrations = $this->getMigrationsForVersion($currentVersion, 1);

        if (empty($migrations)) {
            return null;
        }

        return array_shift($migrations);
    }

    /** * Return an array of Migrations that have a higher version than $currentVersion * The array is indexed by Version * * @param int $currentVersion * @param int $limit * * @throws Exception * * @return array */
if (!is_dir(UPDATE_ASSET_PATH . '/migrations/')) {
            $this->IOHelper->writeln('skipped...');

            return 1;
        }

        /** @var MigrationManager $manager */
        $manager = $this->container->get('migration.manager');

        $currentVersion = $manager->getCurrentVersion();

        $versions = $manager->getMigrationsForVersion($currentVersion);

        $progress = $this->IOHelper->createProgressBar(\count($versions));
        $progress->start();

        $step = new MigrationStep($manager);
        $offset = 0;
        do {
            $progress->setProgress($offset);
            $result = $step->run($offset);
            if ($result instanceof ErrorResult) {
                throw new Exception($result->getMessage(), 0, $result->getException());
            }

    public function run($offset$totalCount = null)
    {
        if ($offset == 0) {
            $this->migrationManager->createSchemaTable();
        }

        $currentVersion = $this->migrationManager->getCurrentVersion();

        if (!$totalCount) {
            $totalCount = \count($this->migrationManager->getMigrationsForVersion($currentVersion));
        }

        $migration = $this->migrationManager->getNextMigrationForVersion($currentVersion);

        if ($migration === null) {
            return new FinishResult($offset$totalCount);
        }

        try {
            $this->migrationManager->apply($migration, AbstractMigration::MODUS_UPDATE);
        } catch (Exception $e) {
            
Home | Imprint | This part of the site doesn't use cookies.