Support options `batch` for `migrate:rollback`. by albertcht · Pull Request #7531 · hyperf/hyperf

Pull Request Overview

This PR adds batch option support to the migrate:rollback command, allowing users to rollback migrations by batch number instead of just by step count.

  • Adds a new --batch option to the rollback command that accepts a batch number
  • Implements getMigrationsByBatch() method in the migration repository to retrieve migrations by batch number
  • Updates rollback logic to handle batch-based rollbacks alongside existing step-based rollbacks

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
RollbackCommand.php Adds batch option and passes it to migrator
Migrator.php Implements batch rollback logic in getMigrationsForRollback method
MigrationRepositoryInterface.php Adds getMigrationsByBatch method signature
DatabaseMigrationRepository.php Implements getMigrationsByBatch method
DatabaseMigrationRollbackCommandTest.php Updates tests to include batch parameter and adds batch-specific test
DatabaseMigrationRepositoryTest.php Adds test for getMigrationsByBatch method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.