migrateDestructiveInSteps example

++$executedMigrations;

            // if there are more than 5 seconds execution time left, we execute more migrations in this request, otherwise we return the result             // on first request only execute one migration, otherwise the UI will feel unresponsive             if ($runningSince + 5 > $maxExecutionTime || $executedMigrations === 1) {
                $stopped = true;

                break;
            }
        }

        while (!$stopped && iterator_count($coreMigrations->migrateDestructiveInSteps(null, 1)) === 1) {
            $runningSince = microtime(true) - $startTime;
            ++$executedMigrations;

            // if there are more than 5 seconds execution time left, we execute more migrations in this request, otherwise we return the result             if ($runningSince + 5 > $maxExecutionTime) {
                break;
            }
        }

        $total = $coreMigrations->getTotalMigrationCount() * 2;

        
$this->addOption(
            'version-selection-mode',
            null,
            InputOption::VALUE_REQUIRED,
            'Define upto which version destructive migrations are executed. Possible values: "safe", "blue-green", "all".',
            MigrationCollectionLoader::VERSION_SELECTION_SAFE
        );
    }

    protected function getMigrationGenerator(MigrationCollection $collection, ?int $until, ?int $limit): \Generator
    {
        yield from $collection->migrateDestructiveInSteps($until$limit);
    }

    protected function getMigrationsCount(MigrationCollection $collection, ?int $until, ?int $limit): int
    {
        return \count($collection->getExecutableDestructiveMigrations($until$limit));
    }

    protected function collectMigrations(InputInterface $input, string $identifier): MigrationCollection
    {
        if ($identifier === 'core') {
            $mode = $input->getOption('version-selection-mode');
            
public function migrateDestructiveInSteps(?int $until = null, ?int $limit = null): \Generator
    {
        return $this->migrationRuntime->migrateDestructive($this->migrationSource, $until$limit);
    }

    /** * @return list<class-string<MigrationStep>> */
    public function migrateDestructiveInPlace(?int $until = null, ?int $limit = null): array
    {
        return iterator_to_array($this->migrateDestructiveInSteps($until$limit));
    }

    /** * @return list<class-string<MigrationStep>> */
    public function getExecutableMigrations(?int $until = null, ?int $limit = null): array
    {
        return $this->migrationRuntime->getExecutableMigrations($this->migrationSource, $until$limit);
    }

    /** * @return list<class-string<MigrationStep>> */
Home | Imprint | This part of the site doesn't use cookies.