Get list of migrations.

@param int $steps

@return array
962167
public function getMigrations($steps)
    {
        $query = $this->table()->where('batch', '>=', '1');

        return $query->orderBy('migration', 'desc')->take($steps)->get()->all();
    }
1313421
protected function getMigrationsFilteredByConnection(): array
	{
		$migrations = $this->findMigrations();

		$connectionName = $this->getConnectionName();

		$defaultConnectionName = $this->getDefaultConnectionName();

		foreach($migrations as $key => $migration)
		{
			$migrationConnectionName = (new ReflectionClass($this->getFullyQualifiedMigration($migration)))
			->newInstanceWithoutConstructor()
			->getConnectionName() ?? $defaultConnectionName;

			if($connectionName !== $migrationConnectionName)
			{
				unset($migrations[$key]);
			}
		}

		return $migrations;
	}
428312
protected function executedMigrations()
    {
        $result = [];
        foreach ($this->getRepository()->get() as $row) {
            $result[] = $row['migration'];
        }

        return $result;
    }
547476
private function getTotalSteps()
    {
        $total = 0;

        if (null != $this->configuration) {
            foreach ($this->configuration['steps']['groups'] as &$group) {
                $total += count($group['steps']);
            }
        }

        return $total;
    }
1163743
def _get_all_migrations():
    
    from . import migrations

    package = migrations
    prefix = package.__name__ + '.'
    all_migrations = []
    for importer, modname, ispkg in pkgutil.iter_modules(package.__path__, prefix):
        version = int(modname.split('.')[-1].split('_')[0])
        all_migrations.append((version, modname))

    all_migrations = sorted(all_migrations, key=lambda x: x[0])
    return all_migrations
1091905
def get_step_table_names(steps):
    
    table_names = set()
    for s in steps:
        table_names |= get_step(s)._tables_used()
    return list(table_names)
234829
public function getMigratedVersions()
    {
        $this->createMigrationCollection();

        $cursor = $this->getCollection()->find();
        $versions = [];
        foreach ($cursor as $record) {
            $versions[] = $record['v'];
        }

        return $versions;
    }
376992
protected function getMigrationFiles()
    {
        $config = $this->getConfig();
        $paths = $config->getMigrationPaths();
        $files = [];

        foreach ($paths as $path) {
            $files[] = Util::glob($path . DIRECTORY_SEPARATOR . '*.php');
        }

        $files = array_merge(...$files);

        // glob() can return the same file multiple times
        // This will cause the migration to fail with a
        // false assumption of duplicate migrations
        // http://php.net/manual/en/function.glob.php#110340
        return array_unique($files);
    }
1091251
protected function getNewMigrations()
    {
        $applied = [];
        foreach ($this->getMigrationHistory(null) as $class => $time) {
            $applied[trim($class, '\\')] = true;
        }

        $migrationPaths = [];
        if (is_array($this->migrationPath)) {
            foreach ($this->migrationPath as $path) {
                $migrationPaths[] = [$path, ''];
            }
        } elseif (!empty($this->migrationPath)) {
            $migrationPaths[] = [$this->migrationPath, ''];
        }
        foreach ($this->migrationNamespaces as $namespace) {
            $migrationPaths[] = [$this->getNamespacePath($namespace), $namespace];
        }

        $migrations = [];
        foreach ($migrationPaths as $item) {
            [$migrationPath, $namespace] = $item;
            if (!file_exists($migrationPath)) {
                continue;
            }
            $handle = opendir($migrationPath);
            while (($file = readdir($handle)) !== false) {
                if ($file === '.' || $file === '..') {
                    continue;
                }
                $path = $migrationPath . DIRECTORY_SEPARATOR . $file;
                if (preg_match('/^(m(\d{6}_?\d{6})\D.*?)\.php$/is', $file, $matches) && is_file($path)) {
                    $class = $matches[1];
                    if (!empty($namespace)) {
                        $class = $namespace . '\\' . $class;
                    }
                    $time = str_replace('_', '', $matches[2]);
                    if (!isset($applied[$class])) {
                        $migrations[$time . '\\' . $class] = $class;
                    }
                }
            }
            closedir($handle);
        }
        ksort($migrations);

        return array_values($migrations);
    }
136602
public function getAvailableVersions()
    {
        $availableVersions = [];
        foreach ($this->migrations as $migration) {
            $availableVersions[] = $migration->getVersion();
        }

        return $availableVersions;
    }
1142657
public function rollback($paths = [], array $options = [])
    {
        $this->notes = [];
        $rolledBack  = [];

        $migrations = $this->getRanMigrations();
        $files = $this->getMigrationFiles($paths);
        $count = count($migrations);

        if ($count === 0) {
            $this->note('<info>Nothing to rollback.</info>');
        } else {
            $this->requireFiles($files);

            $steps = Arr::get($options, 'step', 0);
            if ($steps == 0) {
                $steps = 1;
            }

            $lastBatch = $this->repository->getLastBatchNumber();
            $stepDown  = false;

            foreach ($migrations as $migration) {
                $migration = (object) $migration;

                if ($lastBatch > $migration->batch && $stepDown) {
                    $steps--;

                    $stepDown  = false;
                    $lastBatch = $migration->batch;
                }

                if ($steps <= 0) {
                    break;
                }

                if (Arr::exists($files, $migration->migration)) {
                    $rolledBack[] = $files[$migration->migration];

                    $stepDown = true;

                    $this->runDown(
                        $files[$migration->migration],
                        $migration, Arr::get($options, 'pretend', false)
                    );
                }
            }
        }

        return $rolledBack;
    }
1108307
protected function getMigrationPaths()
    {
        // If the package is in the list of migration paths we received we will put
        // the migrations in that path. Otherwise, we will assume the package is
        // is in the package directories and will place them in that location.
        if (! is_null($package = $this->option('package'))) {
            return $this->getPackageMigrationPaths($package);
        }

        return parent::getMigrationPaths();
    }
1082574
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 [root_path($this->option('path'))];
        }

        return array_merge(
            [$this->getMigrationPath()],
            $this->container['migrator']->paths()
        );
    }
947378
public function up($steps = PHP_INT_MAX)
    {
        $context = $this->getCommandContext();
        $current = $this->getCurrentVersion();
        $versions = array_filter($this->getVersions(),
               function ($version) use ($current) {
                   return $version > $current;
           }
       );

        sort($versions);
        $versions = array_slice($versions, 0, $steps);

        $context->versions = $versions;

        $this->getCommandChain()->run('before.migration', $context);

        foreach ($versions as $version) {
            $context->version = $version;
            $this->getCommandChain()->run('before.version.up', $context);
            $this->_run('up', $version);
            $this->getCommandChain()->run('after.version.up', $context);
            $this->setCurrentVersion($version);
        }

        $this->getCommandChain()->run('after.migration', $context);
    }
1277086
public function getMigrations($reverse = false)
    {
        $files = $this->laravel['files']->glob($this->getPath().'/*_*.php');

        // Once we have the array of files in the directory we will just remove the
        // extension and take the basename of the file which is all we need when
        // finding the migrations that haven't been run against the databases.
        if ($files === false) {
            return array();
        }

        $files = array_map(function ($file) {
            return str_replace('.php', '', basename($file));

        }, $files);

        // Once we have all of the formatted file names we will sort them and since
        // they all start with a timestamp this should give us the migrations in
        // the order they were actually created by the application developers.
        sort($files);

        if ($reverse) {
            return array_reverse($files);
        }

        return $files;
    }
1189839
private function getMigrationInstances(array $migration_class_file_path_map)
    {
        $result = [];

        foreach ($migration_class_file_path_map as $migration_class => $migration_file_path) {
            if (is_file($migration_file_path)) {
                require_once $migration_file_path;

                if (class_exists($migration_class, false)) {
                    $reflection = new ReflectionClass($migration_class);

                    if ($reflection->implementsInterface(MigrationInterface::class) && !$reflection->isAbstract()) {
                        $result[$migration_class] = new $migration_class($this->connection, $this->log);
                    }
                } else {
                    throw new RuntimeException("Migration class '$migration_class' not found");
                }
            } else {
                throw new RuntimeException("File '$migration_file_path' not found");
            }
        }

        return $result;
    }
1163011
function nextStep( $step )
    {
        foreach ( $this->StepTable as $key => $tableStep )
        {
            if ( $step['class'] == $tableStep['class'] )
            {
                return $this->StepTable[++$key];
            }
        }
        $retValue = null;
        return $retValue;
    }