We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d2e50af commit 3cfb940Copy full SHA for 3cfb940
1 file changed
system/Commands/Database/MigrateRollback.php
@@ -15,6 +15,7 @@
15
16
use CodeIgniter\CLI\BaseCommand;
17
use CodeIgniter\CLI\CLI;
18
+use CodeIgniter\Database\MigrationRunner;
19
use Throwable;
20
21
/**
@@ -78,10 +79,23 @@ public function run(array $params)
78
79
// @codeCoverageIgnoreEnd
80
}
81
82
+ /** @var MigrationRunner $runner */
83
$runner = service('migrations');
84
85
try {
86
$batch = $params['b'] ?? CLI::getOption('b') ?? $runner->getLastBatch() - 1;
87
+
88
+ if (is_string($batch)) {
89
+ if (! ctype_digit($batch)) {
90
+ CLI::error('Invalid batch number: ' . $batch, 'light_gray', 'red');
91
+ CLI::newLine();
92
93
+ return EXIT_ERROR;
94
+ }
95
96
+ $batch = (int) $batch;
97
98
99
CLI::write(lang('Migrations.rollingBack') . ' ' . $batch, 'yellow');
100
101
if (! $runner->regress($batch)) {
0 commit comments