protected function getNewMigrations() { if (!$this->module) { $migrations = parent::getNewMigrations(); } else { $migrations = array(); } $module = $this->module ?: true; $applied = array(); foreach ($this->getMigrationHistory(-1, $module) as $version => $time) { if (preg_match('@^(.+:)m(\\d{6}_\\d{6})_@', $version, $matches)) { $applied[$matches[1] . $matches[2]] = true; } } if (is_array($this->moduleMigrationPaths)) { foreach ($this->moduleMigrationPaths as $module => $modulePath) { $migrations = array_merge($migrations, $this->_getModuleMigrations($module, $applied)); } } usort($migrations, function ($a, $b) { if (preg_match('@m(\\d{6}_\\d{6})@', $a, $matches)) { $a = $matches[1]; } if (preg_match('@m(\\d{6}_\\d{6})@', $b, $matches)) { $b = $matches[1]; } if ($a < $b) { return -1; } elseif ($a > $b) { return 1; } return 0; }); return $migrations; }
protected function getNewMigrations() { $this->_scopeNewMigrations = true; $migrations = array(); // get new migrations for all new modules foreach ($this->_runModulePaths as $module => $path) { $this->migrationPath = Yii::getPathOfAlias($path); foreach (parent::getNewMigrations() as $migration) { if ($this->_scopeAddModule) { $migrations[$migration] = $module . $this->moduleDelimiter . $migration; } else { $migrations[$migration] = $migration; } } } $this->_scopeNewMigrations = false; ksort($migrations); return array_values($migrations); }