Browse Source

Module enabled migration apply both up and safeUp methods

master
Egorka 6 years ago
parent
commit
5fe96f10d3
  1. 9
      core/services/ModuleService.php

9
core/services/ModuleService.php

@ -95,14 +95,19 @@ class ModuleService
$migrationFile = basename($migrationPath);
$migration = str_replace('.php', '', $migrationFile);
if (!$this->migrationExists($migration)) {
$addMigrationRecord = false;
// run migration
require $migrationPath;
$obj = new $migration;
if (method_exists($obj, 'safeUp')) {
$obj->safeUp();
Yii::$app->moduleManager->appendToMigrationTable($migration);
} elseif (method_exists($obj, 'up')) {
$addMigrationRecord = true;
}
if (method_exists($obj, 'up')) {
$obj->up();
$addMigrationRecord = true;
}
if ($addMigrationRecord) {
Yii::$app->moduleManager->appendToMigrationTable($migration);
}
}

Loading…
Cancel
Save