Skip to content

Conversation

@dereuromark
Copy link
Member

Add Migrations 5.0 rector rules for PHINX_TYPE_* constant renaming

Summary

This PR adds rector rules to automatically upgrade migrations from the deprecated PHINX_TYPE_* constants to the new TYPE_* constants introduced in Migrations 5.0.

Changes

  • ✅ Add config/rector/migrations50.php entry point
  • ✅ Add config/rector/sets/migrations50.php with constant rename rules
  • ✅ Update CakePHPSetList with MIGRATIONS_50 constant
  • ✅ Update README.md with migrations50 documentation

Usage

Users can now upgrade their migrations using:

cd /path/to/upgrade
bin/cake upgrade rector --rules migrations50 /path/to/your/app/config

Details

The rules rename all deprecated PHINX_TYPE_* constants to their new TYPE_* equivalents, matching the naming conventions of Cake\Database\Schema\TableSchemaInterface:

Standard Types

  • PHINX_TYPE_STRINGTYPE_STRING
  • PHINX_TYPE_INTEGERTYPE_INTEGER
  • PHINX_TYPE_BOOLEANTYPE_BOOLEAN
  • etc.

Multi-word Types (no underscores)

  • PHINX_TYPE_TINY_INTEGERTYPE_TINYINTEGER
  • PHINX_TYPE_SMALL_INTEGERTYPE_SMALLINTEGER
  • PHINX_TYPE_BIG_INTEGERTYPE_BIGINTEGER

UUID Types (with underscores)

  • PHINX_TYPE_BINARYUUIDTYPE_BINARY_UUID
  • PHINX_TYPE_NATIVEUUIDTYPE_NATIVE_UUID

Geospatial Types

  • PHINX_TYPE_GEOMETRYTYPE_GEOMETRY
  • PHINX_TYPE_POINTTYPE_POINT
  • PHINX_TYPE_LINESTRINGTYPE_LINESTRING
  • PHINX_TYPE_POLYGONTYPE_POLYGON
  • PHINX_TYPES_GEOSPATIALTYPES_GEOSPATIAL

Database-specific Types

  • PHINX_TYPE_YEARTYPE_YEAR (MySQL)
  • PHINX_TYPE_CIDRTYPE_CIDR (PostgreSQL)
  • PHINX_TYPE_INETTYPE_INET (PostgreSQL)
  • PHINX_TYPE_MACADDRTYPE_MACADDR (PostgreSQL)
  • PHINX_TYPE_INTERVALTYPE_INTERVAL (PostgreSQL)

Related Issue

cakephp/migrations#948

Testing

The rector rules can be tested by running them against migration files that use the old constants. Example:

Before:

$table->addColumn('name', AdapterInterface::PHINX_TYPE_STRING)
    ->addColumn('count', AdapterInterface::PHINX_TYPE_INTEGER)
    ->save();

After:

$table->addColumn('name', AdapterInterface::TYPE_STRING)
    ->addColumn('count', AdapterInterface::TYPE_INTEGER)
    ->save();

This adds rector rules to automatically upgrade migrations from the deprecated
PHINX_TYPE_* constants to the new TYPE_* constants introduced in Migrations 5.0.

Changes:
- Add config/rector/migrations50.php entry point
- Add config/rector/sets/migrations50.php with constant rename rules
- Update CakePHPSetList with MIGRATIONS_50 constant
- Update README.md with migrations50 documentation

The rules rename all deprecated PHINX_TYPE_* constants to their new TYPE_*
equivalents, matching the naming conventions of Cake\Database\Schema\TableSchemaInterface:
- PHINX_TYPE_STRING -> TYPE_STRING
- PHINX_TYPE_TINY_INTEGER -> TYPE_TINYINTEGER
- PHINX_TYPE_BINARYUUID -> TYPE_BINARY_UUID
- etc.

See: cakephp/migrations#948
@markstory markstory merged commit af71e65 into cakephp:5.x Nov 21, 2025
3 of 5 checks passed
@dereuromark dereuromark deleted the migrations50-constants branch November 21, 2025 10:25
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.

2 participants