Skip to content

Conversation

@dereuromark
Copy link
Member

Summary

  • Fix phinx backend incorrectly loading RollbackCommand instead of MigrationsRollbackCommand
  • Add regression test for command registration in both backends

Root Cause

When using Migrations.backend = 'phinx' with Bake installed, discoverPlugin() scanned the entire Command/ directory and found both:

  • RollbackCommand (builtin) with defaultName() => 'migrations rollback'
  • MigrationsRollbackCommand (phinx) also returning 'migrations rollback'

Due to alphabetical ordering during discovery, RollbackCommand (R > M) was loaded after MigrationsRollbackCommand, overwriting it.

Fix

Replace discoverPlugin() with explicit command registration for the phinx backend, matching the approach already used for the builtin backend. This ensures only the correct phinx-specific commands are registered.

Fixes #990

When using the phinx backend with Bake installed, discoverPlugin()
was finding both builtin and phinx commands. Since both RollbackCommand
and MigrationsRollbackCommand have the same defaultName(), the builtin
command was overwriting the phinx one due to alphabetical ordering.

This fix explicitly registers only the phinx-specific commands instead
of using discoverPlugin(), matching the approach used for builtin backend.

Fixes #990
@jamisonbryant
Copy link
Contributor

Stan failure is unrelated. GitHub Actions fail.

@markstory markstory merged commit 7a7f9a9 into 4.x Jan 8, 2026
11 of 13 checks passed
@markstory markstory deleted the fix-phinx-rollback-command branch January 8, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phinx backend - "migrations rollback" command uses incorrect RollbackCommand class

4 participants