@return string[][]

@throws MigrationException
322571
public function migrate(
        ?string $to = null,
        ?MigratorConfiguration $migratorConfiguration = null
    ) : array {
        $migratorConfiguration = $migratorConfiguration ?? new MigratorConfiguration();
        $dryRun                = $migratorConfiguration->isDryRun();

        if ($to === null) {
            $to = $this->migrationRepository->getLatestVersion();
        }

        $versions = $this->migrationRepository->getMigrations();

        if (! isset($versions[$to]) && $to > 0) {
            throw UnknownMigrationVersion::new($to);
        }

        $from = $this->migrationRepository->getCurrentVersion();

        $direction = $this->calculateDirection($from, $to);

        $migrationsToExecute = $this->configuration
            ->getMigrationsToExecute($direction, $to);

        /**
         * If
         *  there are no migrations to execute
         *  and there are migrations,
         *  and the migration from and to are the same
         * means we are already at the destination return an empty array()
         * to signify that there is nothing left to do.
         */
        if ($from === $to && count($migrationsToExecute) === 0 && count($versions) !== 0) {
            return $this->noMigrations();
        }

        $output  = $dryRun ? 'Executing dry run of migration' : 'Migrating';
        $output .= ' <info>%s</info> to <comment>%s</comment> from <comment>%s</comment>';

        $this->outputWriter->write(sprintf($output, $direction, $to, $from));

        /**
         * If there are no migrations to execute throw an exception.
         */
        if (count($migrationsToExecute) === 0 && ! $migratorConfiguration->getNoMigrationException()) {
            throw NoMigrationsToExecute::new();
        }

        if (count($migrationsToExecute) === 0) {
            return $this->noMigrations();
        }

        $stopwatchEvent = $this->stopwatch->start('migrate');

        $sql = $this->executeMigration($migrationsToExecute, $direction, $migratorConfiguration);

        $this->endMigration($stopwatchEvent, $migrationsToExecute, $sql);

        return $sql;
    }
933865
private function getMigrationPaths($edition = null)
    {
        $allMigrationPaths = $this->facts->getMigrationPaths();

        if (is_null($edition)) {
            return $allMigrationPaths;
        }

        $migrationPaths = [];
        foreach ($allMigrationPaths as $migrationEdition => $migrationPath) {
            if (strtolower($migrationEdition) === strtolower($edition)) {
                $migrationPaths[$migrationEdition] = $migrationPath;
                break;
            }
        }

        return $migrationPaths;
    }
521771
public function getDownList() {
		$list = $this->getList();
		foreach($list as $migration=>$params) {
			if(isset($params['migrated']))
				unset($list[$migration]);
		}
		return $list;
	}
440316
public function getMigrations()
    {
        if (null === $this->migrations) {
            $phpFiles = $this->getMigrationFiles();

            // filter the files to only get the ones that match our naming scheme
            $fileNames = [];
            /** @var AbstractMigration[] $versions */
            $versions = [];

            foreach ($phpFiles as $filePath) {
                if (Util::isValidMigrationFileName(basename($filePath))) {
                    $version = Util::getVersionFromFileName(basename($filePath));

                    if (isset($versions[$version])) {
                        throw new \InvalidArgumentException(sprintf('Duplicate migration - "%s" has the same version as "%s"',
                            $filePath, $versions[$version]->getVersion()));
                    }

                    $config = $this->getConfig();
                    $namespace = $config->getMigrationNamespaceByPath(dirname($filePath));

                    // convert the filename to a class name
                    $class = (null === $namespace ? '' : $namespace . '\\') . Util::mapFileNameToClassName(basename($filePath));

                    if (isset($fileNames[$class])) {
                        throw new \InvalidArgumentException(sprintf(
                            'Migration "%s" has the same name as "%s"',
                            basename($filePath),
                            $fileNames[$class]
                        ));
                    }

                    $fileNames[$class] = basename($filePath);

                    // load the migration file
                    /** @noinspection PhpIncludeInspection */
                    require_once $filePath;
                    if (!class_exists($class)) {
                        throw new \InvalidArgumentException(sprintf(
                            'Could not find class "%s" in file "%s"',
                            $class,
                            $filePath
                        ));
                    }

                    // instantiate it
                    $migration = new $class($version, $this->getCommand());

                    if (!($migration instanceof AbstractMigration)) {
                        throw new \InvalidArgumentException(sprintf(
                            'The class "%s" in file "%s" must extend \Hail\Database\Migration\AbstractMigration',
                            $class,
                            $filePath
                        ));
                    }

                    $versions[$version] = $migration;
                }
            }

            ksort($versions);
            $this->setMigrations($versions);
        }

        return $this->migrations;
    }
1219745
private function fetchMigrations()
    {
        if ( ! isset($this->migrations)) {
            return null;
        }

        if (empty($this->migrations)) {
            return array();
        }

        $migrations = array();
        $connection = $this->entityManager->getConnection();
        $driver     = $connection->getDatabasePlatform()->getName();

        foreach ($this->migrations as $migration) {
            $files = glob($migration . '/*.sql');

            if (empty($files)) {
                $files = glob($migration . '/' . $driver . '/*.sql');

                if (empty($files)) {
                    continue;
                }
            }

            foreach ($files as $file) {
                $version = basename($file, '.sql');

                if (preg_match('~^[vV]([^_]+)_~', $version, $matches)) {
                    $version = $matches[1];
                }

                $migrations[$version] = $file;
            }
        }

        uksort($migrations, 'version_compare');

        return $migrations;
    }
138080
public function fetch()
    {
        $parsedName = $this->getParsedMigrationName();
        $parsedFields = $this->getParsedMigrationFields();

        return [
            'class' => $this->getClass(),
            'up'    => $this->getMigrationUp($parsedName, $parsedFields),
            'down'  => $this->getMigrationDown($parsedName, $parsedFields)
        ];
    }
660565
public function getRanMigrations()
    {
        $query = $this->resolveConnection($this->connection)->table($this->table);

        return $query->orderBy('batch', 'desc')->orderBy('migration', 'desc')->get();
    }
1199858
protected function getMigrationPaths()
    {
        // Here, we will check to see if a path option has been defined. If it has we will
        // use the path relative to the root of the installation folder so our database
        // migrations may be run for any customized path from within the application.
        if ($this->input->hasOption('path') && $this->option('path')) {
            return collect($this->option('path'))->map(function ($path) {
                return $this->laravel->basePath().'/'.$path;
            })->all();
        }

        return [$this->getMigrationPath()];
    }
229905
protected function outputMigrationList(array $migrations): void
	{
		$tableBody = [];

		foreach($migrations as $migration)
		{
			$name = $migration->version;

			if(!empty($migration->package))
			{
				$name .= ' (' . $migration->package . ')';
			}

			$description = $this->resolve($migration)->getDescription();

			$tableBody[] = [$name, $description];
		}

		$this->table(['Migration', 'Description'], $tableBody);
	}
36552
public function getMigrations()
    {
        if (count($this->_migrations) <= 0 && $this->_config !== null) {
            $versions = [];
            $paths = $this->_config->getMigrationPaths();
            foreach ($paths as $path) {
                $files = glob($path . '/*.php');
                foreach ($files as $file) {
                    $fileName = basename($file);
                    if (Util::isValidMigrationFileName($fileName)) {
                        $version = Util::getVersionFromFileName($fileName);
                        if (Arr::key($version, $versions)) {
                            throw new \InvalidArgumentException(
                                __d(
                                    'extensions',
                                    'Duplicate migration - "%s" has the same version as "%s"',
                                    $file,
                                    $versions[$version]->getVersion()
                                )
                            );
                        }

                        //  Convert the filename to a class name.
                        $class = Util::mapFileNameToClassName($fileName);

                        /** @noinspection PhpIncludeInspection */
                        require_once $file;
                        if (!class_exists($class)) {
                            throw new \InvalidArgumentException(
                                __d('extensions', 'Could not find class "%s" in file "%s"', $class, $file)
                            );
                        }

                        //  Instantiate migration class.
                        $migration = new $class($version);
                        if (!($migration instanceof AbstractMigration)) {
                            throw new \InvalidArgumentException(
                                __d(
                                    'extensions',
                                    'The class "%s" in file "%s" must extend \Phinx\Migration\AbstractMigration',
                                    $class,
                                    $file
                                )
                            );
                        }

                        $versions[$version] = $migration;
                    }
                }
            }

            ksort($versions);
            $this->_migrations = $versions;
        }

        return $this->_migrations;
    }
1101162
protected function extract(string $migration): array
    {
        if (strpos($migration, '\\') === false) {
            $file = Yii::getAlias($this->migrationPath . DIRECTORY_SEPARATOR . $migration . '.php');

            if (!file_exists($file)) {
                throw new ErrorException("File '{$file}' can not be found! Check migration history table.");
            }

            require_once $file;
        }

        $subject = new $migration;
        $subject->db = $this->db;
        $subject->up();

        return $subject->changes;
    }
443174
def get_migration_files(self):
        """"""
        migrations = (re.match(MigrationFile.PATTERN, filename)
                      for filename in os.listdir(self.directory))
        migrations = (MigrationFile(m.group('id'), m.group(0))
                      for m in migrations if m)
        return sorted(migrations, key=lambda m: m.id)
970014
public function getMigrationsFiles()
    {
        $files = [];
        foreach ($this->orm->getComponents(true) as $component) {
            if ($component instanceof AppInterface) {
                $fileHandler = FileHandler::createObject(
                    [
                        'path' => $component->getMigrationsPath(),
                    ]
                );

                $files[$component->getName()] = $fileHandler->getPathFiles();
            }
        }

        return $files;
    }
714015
public function getMigrationsNotApplied()
    {
        $migrationsNotApplied = [];
        $migrations = $this->getAllMigrations();

        foreach ($migrations as $migration) {
            if (!$migration->isApplied()) {
                $migrationsNotApplied[] = $migration;
            }
        }

        return $migrationsNotApplied;
    }
981712
public function getMigrations( )
    {
        $migrations = array();
        
        $dir = opendir( $this->migrationPath );
        
        while ( ( $file = readdir( $dir ) ) !== FALSE )
        {
            if ( '.' !== $file && '..' !== $file )
            {
                $migrations[] = str_replace( '.php', '', $file );
            }
        }
        
        closedir( $dir );
        
        usort( $migrations, array( $this, '_sortMigrations' ) );
        
        return $this->filter( self::ON_GET_MIGRATIONS_FILTER, $migrations );
    }
67125
public function getAppliedMigrations( )
    {
        $query = "SELECT * FROM $this->migrationTable";
        
        $applied = $this->db->query( $query );
        
        $list = array();
        
        foreach( $applied as $mig )
        {
            $list[] = $mig[ 'migration_name' ];
        }
        
        $list = array_reverse( $list );
        
        return $this->filter( self::ON_GET_APPLIED_MIGRATIONS_FILTER, $list );
    }
821060
protected function findPackageMigrations(): array
	{
		$migrations = [];

		foreach($this->application->getPackages() as $package)
		{
			foreach($this->fileSystem->glob($package->getPath() . '/src/migrations/*.php') as $migration)
			{
				$migrations[] = (object) ['package' => $package->getName(), 'version' => $this->getBasename($migration)];
			}
		}

		return $migrations;
	}