Skip to content

Conversation

@dereuromark
Copy link
Member

Resolves #463

Root Cause

The bug was in src/Util/TableFinder.php:72. The code incorrectly treated the --plugin option the same as --require-table, filtering tables to only include those with corresponding Table classes in the plugin. When creating
an initial migration snapshot for a plugin (before Table classes exist), this resulted in an empty migration.

The Fix

Changed line 72 in src/Util/TableFinder.php:

// Before (buggy)
if ($options['require-table'] === true || $options['plugin']) {

// After (fixed)  
if ($options['require-table'] === true) {

Behavior Changes

Before:

  • --plugin option would filter tables to only include those with Table classes in the plugin
  • Made it impossible to create initial snapshots for plugins with custom connections

After:

  • --plugin option only determines where the migration file is saved
  • All tables from the specified connection are included (excluding phinxlog tables)
  • Use --require-table if you want to filter by existing Table classes

I wonder: Is including the plugins OK? or will this introduce too many tables or alike?

@dereuromark dereuromark added this to the 4.x (CakePHP 5) milestone Nov 6, 2025
@dereuromark dereuromark added the bug label Nov 6, 2025
@dereuromark dereuromark marked this pull request as draft November 6, 2025 18:07
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.

Unable to bake migrations migration_snapshot in the plugin using another connection

2 participants