Skip to content

Conversation

@dereuromark
Copy link
Member

@dereuromark dereuromark commented Nov 6, 2025

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

@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
@dereuromark dereuromark marked this pull request as ready for review November 12, 2025 12:35
)
->create();

$this->table('special_pks', ['id' => false, 'primary_key' => ['id']])
Copy link
Member

Choose a reason for hiding this comment

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

Is this the expected behavior now? Generating a migration for a plugin without --require-table will include every table in the database?

Copy link
Member Author

@dereuromark dereuromark Nov 13, 2025

Choose a reason for hiding this comment

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

Check the initial report. I think it does make sense as outlined above, since otherwise you couldnt use it for plugins initially at all.

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

3 participants