Browse Source

Merge pull request #10017 from nikashitsa/applied-migrations-report

Added total applied migrations to final report
tags/3.0.0-alpha1
Alexander Makarov 9 years ago
parent
commit
f6995e9e39
  1. 1
      framework/CHANGELOG.md
  2. 10
      framework/console/controllers/BaseMigrateController.php

1
framework/CHANGELOG.md

@ -30,6 +30,7 @@ Yii Framework 2 Change Log
- Bug #9924: Fixed `yii.js` handleAction corrupted parameter values containing quote (") character (silverfire)
- Bug #9984: Fixed wrong captcha color in case Imagick is used (DrDeath72)
- Bug: Fixed generation of canonical URLs for `ViewAction` pages (samdark)
- Enh #8649: Added total applied migrations to final report (vernik91)
- Enh #3506: Added `\yii\validators\IpValidator` to perform validation of IP addresses and subnets (SilverFire, samdark)
- Enh #7341: Client validation now skips disabled inputs (SamMousa)
- Enh #7581: Added ability to specify range using anonymous function in `RangeValidator` (RomeroMsk)

10
framework/console/controllers/BaseMigrateController.php

@ -124,14 +124,19 @@ abstract class BaseMigrateController extends Controller
}
$this->stdout("\n");
$applied = 0;
if ($this->confirm('Apply the above ' . ($n === 1 ? 'migration' : 'migrations') . '?')) {
foreach ($migrations as $migration) {
if (!$this->migrateUp($migration)) {
$this->stdout("\n$applied from $n " . ($applied === 1 ? 'migration was' : 'migrations were') ." applied.\n", Console::FG_RED);
$this->stdout("\nMigration failed. The rest of the migrations are canceled.\n", Console::FG_RED);
return self::EXIT_CODE_ERROR;
}
$applied++;
}
$this->stdout("\n$n " . ($n === 1 ? 'migration was' : 'migrations were') ." applied.\n", Console::FG_GREEN);
$this->stdout("\nMigrated up successfully.\n", Console::FG_GREEN);
}
}
@ -180,14 +185,18 @@ abstract class BaseMigrateController extends Controller
}
$this->stdout("\n");
$reverted = 0;
if ($this->confirm('Revert the above ' . ($n === 1 ? 'migration' : 'migrations') . '?')) {
foreach ($migrations as $migration) {
if (!$this->migrateDown($migration)) {
$this->stdout("\n$reverted from $n " . ($reverted === 1 ? 'migration was' : 'migrations were') ." reverted.\n", Console::FG_RED);
$this->stdout("\nMigration failed. The rest of the migrations are canceled.\n", Console::FG_RED);
return self::EXIT_CODE_ERROR;
}
$reverted++;
}
$this->stdout("\n$n " . ($n === 1 ? 'migration was' : 'migrations were') ." reverted.\n", Console::FG_GREEN);
$this->stdout("\nMigrated down successfully.\n", Console::FG_GREEN);
}
}
@ -253,6 +262,7 @@ abstract class BaseMigrateController extends Controller
return self::EXIT_CODE_ERROR;
}
}
$this->stdout("\n$n " . ($n === 1 ? 'migration was' : 'migrations were') ." redone.\n", Console::FG_GREEN);
$this->stdout("\nMigration redone successfully.\n", Console::FG_GREEN);
}
}

Loading…
Cancel
Save