Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument #2 ($version) must be of type ?int, string given #2231

Closed
kolorafa opened this issue Oct 19, 2023 · 3 comments
Closed

Argument #2 ($version) must be of type ?int, string given #2231

kolorafa opened this issue Oct 19, 2023 · 3 comments
Labels

Comments

@kolorafa
Copy link

./bin/cake migrations migrate -t 20231019152508

TypeError: Phinx\Migration\Manager::migrate(): Argument #2 ($version) must be of type ?int, string given, called in /app/vendor/robmorgan/phinx/src/Phinx/Console/Command/Migrate.php on line 124 and defined in /app/vendor/robmorgan/phinx/src/Phinx/Migration/Manager.php:312
Stack trace:
#0 /app/vendor/robmorgan/phinx/src/Phinx/Console/Command/Migrate.php(124): Phinx\Migration\Manager->migrate('default', '20231019152508', false)
#1 /app/vendor/cakephp/migrations/src/Command/Phinx/CommandTrait.php(37): Phinx\Console\Command\Migrate->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#2 /app/vendor/cakephp/migrations/src/Command/Phinx/Migrate.php(88): Migrations\Command\Phinx\Migrate->parentExecute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /app/vendor/symfony/console/Command/Command.php(326): Migrations\Command\Phinx\Migrate->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /app/vendor/symfony/console/Application.php(1063): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /app/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand(Object(Migrations\Command\Phinx\Migrate), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /app/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /app/vendor/cakephp/migrations/src/Command/MigrationsCommand.php(127): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /app/vendor/cakephp/cakephp/src/Console/BaseCommand.php(192): Migrations\Command\MigrationsCommand->execute(Object(Cake\Console\Arguments), Object(Cake\Console\ConsoleIo))
#9 /app/vendor/cakephp/migrations/src/Command/MigrationsCommand.php(199): Cake\Console\BaseCommand->run(Array, Object(Cake\Console\ConsoleIo))
#10 /app/vendor/cakephp/cakephp/src/Console/CommandRunner.php(327): Migrations\Command\MigrationsCommand->run(Array, Object(Cake\Console\ConsoleIo))
#11 /app/vendor/cakephp/cakephp/src/Console/CommandRunner.php(168): Cake\Console\CommandRunner->runCommand(Object(Migrations\Command\MigrationsMigrateCommand), Array, Object(Cake\Console\ConsoleIo))
#12 /app/bin/cake.php(10): Cake\Console\CommandRunner->run(Array)
#13 {main}
@BBBUlmer
Copy link

BBBUlmer commented Oct 27, 2023

+1 Same here, when using with robmorgan/phinx

What I did: removed composer.lock and did a fresh new composer install which in return resulted in "robmorgan/phinx" version 0.15.2 being installed.

The error remained when running vendor/bin/phinx rollback -t 0.


Update: I am sorry for possibly causing confusion. The error was solved on our side, as we actually did not use vendor/bin/phinx rollback -t 0 but rather vendor/bin/phinx migrate -t {existing migration number} which does not work.

When using the correct -d parameter it works fine. It seems that the -d option should be used when migrating down instead of the -t which fails if the migration version was already migrated.

The docs on migrate tell this:

 The migrate command runs all available migrations, optionally up to a specific version
  
  phinx migrate -e development
  phinx migrate -e development -t 20110103081132
  phinx migrate -e development -d 20110103
  phinx migrate -e development -v

@wallacio
Copy link
Contributor

You haven't "solved" anything as such - you've found a genuine bug. I've opened a more detailed issue at #2240.

@dereuromark
Copy link
Member

Solved and merged, thx @wallacio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants