mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
fix: "migration:rollback -b" does not work due to TypeError
This commit is contained in:
parent
d2e50affec
commit
3cfb940551
@ -15,6 +15,7 @@ namespace CodeIgniter\Commands\Database;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use CodeIgniter\Database\MigrationRunner;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@ -78,10 +79,23 @@ class MigrateRollback extends BaseCommand
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/** @var MigrationRunner $runner */
|
||||
$runner = service('migrations');
|
||||
|
||||
try {
|
||||
$batch = $params['b'] ?? CLI::getOption('b') ?? $runner->getLastBatch() - 1;
|
||||
|
||||
if (is_string($batch)) {
|
||||
if (! ctype_digit($batch)) {
|
||||
CLI::error('Invalid batch number: ' . $batch, 'light_gray', 'red');
|
||||
CLI::newLine();
|
||||
|
||||
return EXIT_ERROR;
|
||||
}
|
||||
|
||||
$batch = (int) $batch;
|
||||
}
|
||||
|
||||
CLI::write(lang('Migrations.rollingBack') . ' ' . $batch, 'yellow');
|
||||
|
||||
if (! $runner->regress($batch)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user