cakephp / phinx

PHP Database Migrations for Everyone
https://phinx.org
MIT License
4.46k stars 892 forks source link

[0.15.3] Cannot migrate to a specific target with -t #2240

Closed wallacio closed 10 months ago

wallacio commented 10 months ago

Attempting to migrate to a specific target with the -t option, e.g.

php vendor/bin/phinx migrate --target=20210905085019

...throws a TypeError exception:

TypeError: Phinx\Migration\Manager::migrate(): Argument #2 ($version) must be of type ?int, string given, called in /home/vagrant/code/ourclubadmin/vendor/robmorgan/phinx/src/Phinx/Console/Command/Migrate.php on line 124 and defined in /home/vagrant/code/ourclubadmin/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php:312
Stack trace:
#0 /home/vagrant/code/ourclubadmin/vendor/robmorgan/phinx/src/Phinx/Console/Command/Migrate.php(124): Phinx\Migration\Manager->migrate()
#1 /home/vagrant/code/ourclubadmin/vendor/symfony/console/Command/Command.php(326): Phinx\Console\Command\Migrate->execute()
#2 /home/vagrant/code/ourclubadmin/vendor/symfony/console/Application.php(1063): Symfony\Component\Console\Command\Command->run()
#3 /home/vagrant/code/ourclubadmin/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand()
#4 /home/vagrant/code/ourclubadmin/vendor/robmorgan/phinx/src/Phinx/Console/PhinxApplication.php(69): Symfony\Component\Console\Application->doRun()
#5 /home/vagrant/code/ourclubadmin/vendor/symfony/console/Application.php(174): Phinx\Console\PhinxApplication->doRun()
#6 /home/vagrant/code/ourclubadmin/vendor/robmorgan/phinx/bin/phinx(28): Symfony\Component\Console\Application->run()
#7 /home/vagrant/code/ourclubadmin/vendor/bin/phinx(120): include('...')
#8 {main}

Probably caused by Symfony's getOption returning a string for $version:

https://github.com/cakephp/phinx/blob/bd578e72891b9cae4db3af6901ac11f9223228f4/src/Phinx/Console/Command/Migrate.php#L68

...which is used in a method call to migrate() that's expecting an int.

https://github.com/cakephp/phinx/blob/bd578e72891b9cae4db3af6901ac11f9223228f4/src/Phinx/Console/Command/Migrate.php#L124

dereuromark commented 10 months ago

Is that a duplicate of https://github.com/cakephp/phinx/issues/2231 ?

dereuromark commented 10 months ago

Sounds like a cast to string is missing? Maybe someone could make a quick PR here?