migrations icon indicating copy to clipboard operation
migrations copied to clipboard

`Argument version is not defined on this Command` when doing `mark_migrated`

Open LordSimal opened this issue 1 year ago • 1 comments

This is a (multiple allowed):

  • [x] bug

  • [ ] enhancement

  • [ ] feature-discussion (RFC)

  • CakePHP Version: 5.1.0-RC1

  • Migrations plugin version: 4.3.1

  • PHP Version: 8.3.8

  • Platform / OS: MacOS 14.5

What you did

I resetted my migrations via the snapshot command and wanted to mark the newly generated migrations as follows

bin/cake migrations status
+--------+-----------------+----------------+
| Status | Migration ID    | Migration Name |
+--------+-----------------+----------------+
| down   | 20240630123000  | Initial        |
+--------+-----------------+----------------+

bin/cake migrations mark_migrated --target 20240630123000 --only

Expected Behavior

The specified migration is being marked as migrated

Actual Behavior

2024-06-30 14:16:01 error: [Cake\Console\Exception\ConsoleException] Argument `version` is not defined on this Command. Could this be an option maybe? in /home/alfred/gitroot/vendor/cakephp/cakephp/src/Console/Arguments.php on line 223
Stack Trace:
- /home/alfred/gitroot/vendor/cakephp/cakephp/src/Console/Arguments.php:125
- /home/alfred/gitroot/vendor/cakephp/migrations/src/Migration/Manager.php:305
- /home/alfred/gitroot/vendor/cakephp/migrations/src/Command/MarkMigratedCommand.php:130
- /home/alfred/gitroot/vendor/cakephp/cakephp/src/Console/BaseCommand.php:192
- /home/alfred/gitroot/vendor/cakephp/cakephp/src/Console/CommandRunner.php:327
- /home/alfred/gitroot/vendor/cakephp/cakephp/src/Console/CommandRunner.php:168
- /home/alfred/gitroot/bin/cake.php:12
- [main]:

[Cake\Console\Exception\ConsoleException] Argument `version` is not defined on this Command. Could this be an option maybe? in /home/alfred/gitroot/vendor/cakephp/cakephp/src/Console/Arguments.php on line 223

Stack Trace:

Cake\Console\Arguments->assertArgumentExists() - CORE/src/Console/Arguments.php, line 125
Cake\Console\Arguments->getArgument() - ROOT/vendor/cakephp/migrations/src/Migration/Manager.php, line 305
Migrations\Migration\Manager->getVersionsToMark() - ROOT/vendor/cakephp/migrations/src/Command/MarkMigratedCommand.php, line 130
Migrations\Command\MarkMigratedCommand->execute() - CORE/src/Console/BaseCommand.php, line 192
Cake\Console\BaseCommand->run() - CORE/src/Console/CommandRunner.php, line 327
Cake\Console\CommandRunner->runCommand() - CORE/src/Console/CommandRunner.php, line 168
Cake\Console\CommandRunner->run() - ROOT/bin/cake.php, line 12
[main] - [main], line 0

This is caused due to the following change in CakePHP 5.1 https://github.com/cakephp/cakephp/pull/17654

and the fact, that the version argument is request by this line: https://github.com/cakephp/migrations/blob/4.x/src/Migration/Manager.php#L305

LordSimal avatar Jun 30 '24 12:06 LordSimal

My quckfix is to just manually edit that Line 305 in vendor/cakephp/migrations/src/Migration/Manager.php and set

$versionArg = null;

then the command works fine since I currently don't want to mark all migrations.

LordSimal avatar Jun 30 '24 12:06 LordSimal