Skip to content

Fix LONGTEXT columns becoming TEXT in generated migrations#1050

Merged
markstory merged 1 commit into5.xfrom
fix/longtext-limit-mismatch
Mar 12, 2026
Merged

Fix LONGTEXT columns becoming TEXT in generated migrations#1050
markstory merged 1 commit into5.xfrom
fix/longtext-limit-mismatch

Conversation

@dereuromark
Copy link
Member

Summary

Fixes the issue where LONGTEXT columns were being generated as TEXT when using bake migration_diff.

Root cause: Mismatch between CakePHP's LENGTH_LONG constant (4294967295) and migrations' TEXT_LONG constant (2147483647).

Changes:

  1. MigrationHelper::getColumnOption() - Convert LENGTH_LONG to TEXT_LONG when generating migrations, so new migrations get the correct value
  2. MysqlAdapter::mapColumnData() - Accept both constants for backward compatibility, so existing migrations with 4294967295 still work

Note: LENGTH_TINY (255) and LENGTH_MEDIUM (16777215) already match TEXT_TINY and TEXT_MEDIUM, so only LENGTH_LONG needs conversion.

Fixes #1029

The issue was a mismatch between CakePHP's LENGTH_LONG constant (4294967295)
and migrations' TEXT_LONG constant (2147483647).

When using `bake migration_diff`, CakePHP's schema reflection returns
LENGTH_LONG for LONGTEXT columns, but MysqlAdapter expected TEXT_LONG.

This fix:
1. MigrationHelper: Convert LENGTH_LONG to TEXT_LONG when generating migrations
2. MysqlAdapter: Accept both constants for backward compatibility with existing
   migrations that have the wrong value

Fixes #1029
@markstory markstory merged commit c8cfb93 into 5.x Mar 12, 2026
14 checks passed
@markstory markstory deleted the fix/longtext-limit-mismatch branch March 12, 2026 21:10
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.

migration_diff for LONGTEXT create TEXT since v5.x

3 participants