Skip to content

Add count option to migrate #2360

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

Merged
merged 3 commits into from
Jun 9, 2025
Merged

Add count option to migrate #2360

merged 3 commits into from
Jun 9, 2025

Conversation

MasterOdin
Copy link
Member

@MasterOdin MasterOdin commented Jun 9, 2025

Half does #258

PR adds a new -k / --count option to the migrate command which allows for running arbitrary number of migrations, without relying on target or date. Decided to use the -k shorthand as -c, -n, and -t were already used, and it can stand for "kount" which I feel like other tools have done (vs -o as suggested in the issue, which feels more arbitrary).

I decided to deal with rollback in a follow-up PR as there's a workaround for this functionality there, which is just running the rollback command however many times you need.

Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
@MasterOdin MasterOdin force-pushed the feat-migrate-count branch from 1b583fb to a0aaaba Compare June 9, 2025 02:52
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
@MasterOdin MasterOdin merged commit c16ac33 into 0.x Jun 9, 2025
12 checks passed
@MasterOdin MasterOdin deleted the feat-migrate-count branch June 9, 2025 15:09
@@ -38,15 +38,17 @@ protected function configure(): void
$this->setDescription('Migrate the database')
->addOption('--target', '-t', InputOption::VALUE_REQUIRED, 'The version number to migrate to')
->addOption('--date', '-d', InputOption::VALUE_REQUIRED, 'The date to migrate to')
->addOption('--count', '-k', InputOption::VALUE_REQUIRED, 'The number of migrations to run')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldnt -n be better here than k?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-n is taken up by builtin option that comes from symfony console:

 -n, --no-interaction  Do not ask any interactive question

@dereuromark
Copy link
Member

@MasterOdin
I added rollback idea here:
cakephp/migrations#874

Maybe you want to enable this for phinx asap and we can do one full release with all the API consistent.

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

Successfully merging this pull request may close these issues.

2 participants