luya\console\commands\MigrateController::getNewMigrations PHP Method

getNewMigrations() protected method

Returns the migrations that are not applied.
protected getNewMigrations ( ) : array
return array list of new migrations
    protected function getNewMigrations()
    {
        $applied = [];
        foreach ($this->getMigrationHistory(null) as $version => $time) {
            $applied[substr($version, 1, 13)] = true;
        }
        $moduleMigrationDirs = array();
        if (count($this->moduleMigrationDirectories) > 0) {
            foreach ($this->moduleMigrationDirectories as $name => $dir) {
                $moduleMigrationDirs[] = $dir;
            }
        }
        $moduleMigrationDirs[] = $this->migrationPath;
        $migrations = [];
        foreach ($moduleMigrationDirs as $moduleMigrationPath) {
            if (!file_exists($moduleMigrationPath)) {
                continue;
            }
            $handle = opendir($moduleMigrationPath);
            while (($file = readdir($handle)) !== false) {
                if ($file === '.' || $file === '..') {
                    continue;
                }
                if (preg_match('/^(m(\\d{6}_\\d{6})_.*?)\\.php$/', $file, $matches) && is_file($moduleMigrationPath . DIRECTORY_SEPARATOR . $file) && !isset($applied[$matches[2]])) {
                    $migrations[] = $matches[1];
                    $this->migrationFileDirs[$matches[1]] = $moduleMigrationPath;
                }
            }
            closedir($handle);
        }
        sort($migrations);
        return $migrations;
    }