Skip to content

Add BinaryColumnToVarbinaryRector for TYPE_VARBINARY migration#389

Merged
dereuromark merged 2 commits into6.xfrom
feature/binary-to-varbinary-rector
Mar 14, 2026
Merged

Add BinaryColumnToVarbinaryRector for TYPE_VARBINARY migration#389
dereuromark merged 2 commits into6.xfrom
feature/binary-to-varbinary-rector

Conversation

@dereuromark
Copy link
Member

Summary

Adds a Rector rule to help users upgrade migration files for CakePHP 6.0 where TYPE_VARBINARY was added.

Related: cakephp/cakephp#19258

Transformations

Fixed-length binary (with fixed attribute):

// Before
$table->addColumn('hash', 'binary', ['length' => 32, 'fixed' => true]);

// After
$table->addColumn('hash', 'binary', ['length' => 32]);

Variable-length binary (without fixed attribute):

// Before
$table->addColumn('data', 'binary', ['length' => 255]);

// After
$table->addColumn('data', 'varbinary', ['length' => 255]);

Notes

  • This rule targets addColumn() calls in migration files
  • The fixed attribute is removed since binary type is now always fixed-length
  • Columns without fixed => true are converted to varbinary type

Adds a rector rule to help users upgrade to CakePHP 6.0 where
TYPE_VARBINARY was added:

- `addColumn('col', 'binary', ['fixed' => true])` becomes
  `addColumn('col', 'binary', [])` (remove fixed attribute)
- `addColumn('col', 'binary', [...])` becomes
  `addColumn('col', 'varbinary', [...])` (change type)

See: cakephp/cakephp#19258
@dereuromark dereuromark marked this pull request as ready for review March 14, 2026 16:18
@dereuromark dereuromark merged commit 2533552 into 6.x Mar 14, 2026
4 of 5 checks passed
@dereuromark dereuromark deleted the feature/binary-to-varbinary-rector branch March 14, 2026 16:19
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.

1 participant