Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
518124d
Remove commands that are entry points to phinx
markstory Aug 3, 2025
4bec979
Remove more code that supported phinx.
markstory Aug 3, 2025
6bb7d97
Remove commented out code
markstory Aug 3, 2025
890d73a
Fix phpcs and stan builds
markstory Aug 3, 2025
2fb2b12
More fixes
markstory Aug 3, 2025
2860d84
Fix postgres tests.
markstory Aug 3, 2025
35eccb6
Comment out code that will be deleted soon.
markstory Aug 4, 2025
a1e4864
Appease typing gods
markstory Aug 4, 2025
41e7227
Fix phpcs
markstory Aug 4, 2025
43fdbd6
Make pattern work across more php versions
markstory Aug 4, 2025
8272727
Next major - Remove non-builtin commands (#875)
dereuromark Aug 4, 2025
a5728f7
Refactor to fully remove phinx dependency. (#877)
dereuromark Aug 6, 2025
8a96b01
Remove now unused code from imported phinx code (#881)
markstory Aug 8, 2025
fcba1de
5.x Remove adapter getPhinxType (#883)
markstory Aug 9, 2025
18891db
5.x - Remove getSqlType
markstory Aug 10, 2025
183f613
5.x - Remove getSqlType (#884)
dereuromark Aug 10, 2025
9a05c73
5.x - Remove some attributes that are no longer used
markstory Aug 13, 2025
b78b59d
Merge pull request #886 from cakephp/adapter-cleanup
dereuromark Aug 13, 2025
39aca90
Merge branch '4.next' into 5.x
markstory Aug 16, 2025
b583842
Fixups from merge.
markstory Aug 16, 2025
947e86f
5.x Remove usage of deprecated constants (#887)
markstory Aug 19, 2025
9c9186b
Merge branch '4.next' into 5.x
markstory Sep 8, 2025
93e536b
Fix phpcs
markstory Sep 8, 2025
f49eadd
5.x - Require cakephp 5.3 and remove remaining symfony references (#888)
markstory Sep 9, 2025
9a8cd9b
Remove more phinx references (#901)
markstory Sep 13, 2025
2791a5c
5.x - Use cakephp/database for more reflection (#903)
markstory Sep 19, 2025
86364fa
5.x Fix timestampfractional and address some TODOs (#906)
markstory Sep 21, 2025
2023e38
Merge branch '4.next' into 5.x
markstory Sep 27, 2025
81aa362
5.x Replace query usage (#909)
markstory Sep 29, 2025
a038670
Rename Db\Table\Table to TableMetadata (#911)
markstory Oct 7, 2025
64f0978
RFC: File management (#882)
dereuromark Oct 10, 2025
10f80be
5.x Extract an element from the skeleton migration templates (#917)
markstory Oct 12, 2025
54dff0b
Merge 4.next into 5.x
markstory Oct 12, 2025
79a593b
Fix shims for binary types
markstory Oct 12, 2025
74bb86d
Add a TODO for later.
markstory Oct 12, 2025
65fba04
Remove redundant constants
markstory Oct 14, 2025
eb9d395
Merge pull request #918 from cakephp/4next-merge
dereuromark Oct 15, 2025
e3b2633
Fix up anonymous seed support (#920)
dereuromark Oct 19, 2025
830a584
ALlow using --change for snapshots. (#926)
dereuromark Oct 19, 2025
1dcd916
Use and document short seed name. (#927)
dereuromark Oct 19, 2025
52b112b
Add check constraints. (#924)
dereuromark Oct 19, 2025
97bdaa6
Merge branch '4.x' into 5.x
markstory Oct 19, 2025
4624e94
Fixup sqlite default value handling
markstory Oct 19, 2025
23bf8ca
Fix tests. (#929)
dereuromark Oct 20, 2025
69729a3
5.x - Simpler check constraints (#932)
markstory Oct 31, 2025
a04c081
Adding a test for scale 0. (#931)
dereuromark Nov 1, 2025
95fd37b
Use cakephp/database ForeignKey as a base class (#934)
markstory Nov 2, 2025
106ff79
Make seeds a command argument. (#935)
dereuromark Nov 2, 2025
c352a2d
5.x - Use cakephp/database for Index base class (#937)
markstory Nov 2, 2025
507fa45
Merge pull request #943 from cakephp/5.x-tests
dereuromark Nov 4, 2025
6469345
Merge remote-tracking branch 'origin/4.x' into 5.x
dereuromark Nov 4, 2025
74c4336
5.x Database column (#947)
markstory Nov 5, 2025
afc8b26
insertOrSkip() for seeds. (#942)
dereuromark Nov 8, 2025
6d2569a
Fix up SQLServer to return numeric array. (#953)
dereuromark Nov 11, 2025
d21076b
Fix SQLiteAdapter when changing primary key (#954)
dereuromark Nov 13, 2025
93089cc
changeColumn() defaulting. (#941)
dereuromark Nov 13, 2025
10fd8bf
5.x Add first pass at migration table storage abstraction (#951)
markstory Nov 18, 2025
d89c3cf
Constants cleanup.
dereuromark Nov 19, 2025
9261948
Fix up decimal migration_diff (#938)
dereuromark Nov 20, 2025
1d8f683
Wire plugin into TableStorage (#960)
markstory Nov 20, 2025
cc5b6cc
Merge pull request #958 from cakephp/5.x-constants
dereuromark Nov 22, 2025
9fe4430
Add ALGORITHM and LOCK support for MySQL ALTER TABLE operations (#955)
dereuromark Nov 22, 2025
93a55eb
Add seed tracking. (#939)
dereuromark Nov 22, 2025
675c946
Add support for PHP 8.5 in CI workflow
dereuromark Nov 22, 2025
652bb41
Fix missing imports in AbstractAdapter
dereuromark Nov 22, 2025
14db43d
Merge pull request #964 from cakephp/fix-5x-missing-imports
dereuromark Nov 22, 2025
fdc2278
Merge remote-tracking branch 'origin/4.x' into 5.x
dereuromark Nov 22, 2025
3bcd65e
Merge remote-tracking branch 'origin/4.x' into 5.x
dereuromark Nov 23, 2025
a058714
Fix deprecations and postgres CI (#968)
dereuromark Nov 23, 2025
b037e78
Add default value syntax support for bake migration command (#970)
dereuromark Nov 25, 2025
7bdc30e
Add DEFAULT support for CURRENT_DATE, CURRENT_TIME, LOCALTIME, LOCALT…
dereuromark Dec 2, 2025
79f7554
Add unified cake_migrations table support with BC autodetect (#965)
dereuromark Dec 7, 2025
47f960d
Show migration table name in status command output (#978)
dereuromark Dec 12, 2025
a20db19
update stan (#981)
LordSimal Dec 20, 2025
5bbfca7
Fix EntryCommandTest for updated console help format (#983)
dereuromark Dec 26, 2025
037354b
Fix hasTable() returning stale results when mixing API and execute() …
dereuromark Dec 28, 2025
4fad77c
Add table partitioning support for MySQL and PostgreSQL (#966)
dereuromark Jan 5, 2026
b64e00e
Add insertOrUpdate() for upsert operations (#973)
dereuromark Jan 5, 2026
1c06cf8
Strip 'Seed' suffix from seed names in all command output (#984)
dereuromark Jan 6, 2026
1134bb1
Default to signed for all int columns, opt-in for unsigned (#956)
dereuromark Jan 8, 2026
8f5ca19
Update CakePHP dependencies to version 5.3.0
dereuromark Jan 11, 2026
22990fb
Add support for partitionBy() + update() on existing tables (#989)
jamisonbryant Jan 11, 2026
8581673
Merge 4.x into 5.x to resolve conflicts
dereuromark Jan 11, 2026
653da16
Normalize exception handling in command classes (#993)
dereuromark Jan 11, 2026
58e669c
Add --fake flag to seeds run and --seed option to seeds reset (#985)
dereuromark Jan 12, 2026
620d8a1
Remove phinx backend test from 5.x (#996)
dereuromark Jan 13, 2026
bc30a22
Docs: Improve documentation for 5.x release
dereuromark Jan 13, 2026
f546a48
Merge 4.x into 5.x
dereuromark Jan 13, 2026
886c68d
Fix various issues for 5.x release (#998)
dereuromark Jan 13, 2026
dee5b42
Improve insertOrUpdate() API consistency across database adapters (#992)
dereuromark Jan 13, 2026
7ea6311
Resolve merge conflict with 5.x branch
dereuromark Jan 13, 2026
f1ec4ef
Merge pull request #997 from cakephp/docs/5x-improvements
dereuromark Jan 13, 2026
9ca3cad
Merge remote-tracking branch 'origin/4.x' into 5.x
dereuromark Jan 18, 2026
49b3db5
Quote database names in PostgreSQL and SQL Server adapters (#1002)
dereuromark Jan 20, 2026
bf08df2
Improve SQL quoting and fix docblock issues (#1003)
dereuromark Jan 20, 2026
a6f66aa
Fix release readiness issues for 5.x (#1001)
dereuromark Jan 20, 2026
937e915
Improve type safety in nullable detection and comparisons (#1004)
dereuromark Jan 21, 2026
5958b14
Merge branch '4.x' into 5.x
markstory Jan 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 14 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- 3.x
- 4.x
- 4.next
- 5.x
pull_request:
branches:
- '*'
Expand All @@ -20,18 +21,22 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.4']
php-version: ['8.2', '8.5']
db-type: [mariadb, mysql, pgsql, sqlite]
prefer-lowest: ['']
cake_version: ['']
legacy-tables: ['']
include:
- php-version: '8.1'
- php-version: '8.2'
db-type: 'sqlite'
prefer-lowest: 'prefer-lowest'
- php-version: '8.3'
db-type: 'mysql'
- php-version: '8.3'
db-type: 'pgsql'
# Test unified cake_migrations table (non-legacy mode)
- php-version: '8.3'
db-type: 'mysql'
legacy-tables: 'false'
services:
postgres:
image: postgres
Expand Down Expand Up @@ -106,13 +111,9 @@ jobs:
- name: Composer install
run: |
if [[ ${{ matrix.php-version }} == '8.2' || ${{ matrix.php-version }} == '8.3' || ${{ matrix.php-version }} == '8.4' ]]; then
composer install --ignore-platform-req=php
composer install
elif ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
elif ${{ matrix.cake_version != '' }}; then
composer require --dev "cakephp/cakephp:${{ matrix.cake_version }}"
composer require --dev --with-all-dependencies "cakephp/bake:dev-3.next as 3.1.0"
composer update
else
composer update
fi
Expand All @@ -139,6 +140,9 @@ jobs:
export DB_URL='postgres://postgres:pg-password@127.0.0.1/cakephp_test'
export DB_URL_SNAPSHOT='postgres://postgres:pg-password@127.0.0.1/cakephp_snapshot'
fi
if [[ -n '${{ matrix.legacy-tables }}' ]]; then
export LEGACY_TABLES='${{ matrix.legacy-tables }}'
fi
if [[ ${{ matrix.php-version }} == '8.1' && ${{ matrix.db-type }} == 'mysql' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
Expand All @@ -151,11 +155,11 @@ jobs:

testsuite-windows:
runs-on: windows-2022
name: Windows - PHP 8.1 & SQL Server
name: Windows - PHP 8.2 & SQL Server

env:
EXTENSIONS: mbstring, intl, pdo_sqlsrv
PHP_VERSION: '8.1'
PHP_VERSION: '8.2'

steps:
- uses: actions/checkout@v6
Expand Down
2 changes: 1 addition & 1 deletion .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="2.1.17" installed="2.1.17" location="./tools/phpstan" copy="false"/>
<phar name="phpstan" version="2.1.33" installed="2.1.33" location="./tools/phpstan" copy="false"/>
</phive>
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Migrations plugin for CakePHP

[![CI](https://github.com/cakephp/migrations/actions/workflows/ci.yml/badge.svg)](https://github.com/cakephp/migrations/actions/workflows/ci.yml)
[![Coverage Status](https://img.shields.io/codecov/c/github/cakephp/migrations/3.x.svg?style=flat-square)](https://app.codecov.io/github/cakephp/migrations/tree/3.x)
[![Coverage Status](https://img.shields.io/codecov/c/github/cakephp/migrations/5.x.svg?style=flat-square)](https://app.codecov.io/github/cakephp/migrations/tree/5.x)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt)
[![Total Downloads](https://img.shields.io/packagist/dt/cakephp/migrations.svg?style=flat-square)](https://packagist.org/packages/cakephp/migrations)

This is a Database Migrations system for CakePHP.

The plugin consists of a CakePHP CLI wrapper for the [Phinx](https://book.cakephp.org/phinx/0/en/index.html) migrations library.
The plugin provides a complete database migration solution with support for creating, running, and managing migrations.

This branch is for use with CakePHP **5.x**. See [version map](https://github.com/cakephp/migrations/wiki#version-map) for details.

Expand All @@ -33,21 +33,6 @@ If you are using the PendingMigrations middleware, use:
bin/cake plugin load Migrations
```

### Enabling the builtin backend

In a future release, migrations will be switching to a new backend based on the CakePHP ORM. We're aiming
to be compatible with as many existing migrations as possible, and could use your feedback. Enable the
new backend with:

```php
// in app/config/app_local.php
$config = [
// Other configuration
'Migrations' => ['backend' => 'builtin'],
];

```

## Documentation

Full documentation of the plugin can be found on the [CakePHP Cookbook](https://book.cakephp.org/migrations/4/).
Full documentation of the plugin can be found on the [CakePHP Cookbook](https://book.cakephp.org/migrations/5/).
23 changes: 12 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cakephp/migrations",
"description": "Database Migration plugin for CakePHP based on Phinx",
"description": "Database Migration plugin for CakePHP",
"license": "MIT",
"type": "cakephp-plugin",
"keywords": [
Expand All @@ -22,17 +22,16 @@
"source": "https://github.com/cakephp/migrations"
},
"require": {
"php": ">=8.1",
"cakephp/cache": "^5.2.9",
"cakephp/database": "^5.2.9",
"cakephp/orm": "^5.2.9",
"robmorgan/phinx": "^0.16.10"
"php": ">=8.2",
"cakephp/cache": "^5.3.0",
"cakephp/database": "^5.3.0",
"cakephp/orm": "^5.3.0"
},
"require-dev": {
"cakephp/bake": "^3.3",
"cakephp/cakephp": "^5.2.9",
"cakephp/cakephp": "^5.3.0",
"cakephp/cakephp-codesniffer": "^5.0",
"phpunit/phpunit": "^10.5.5 || ^11.1.3 || ^12.2.4"
"phpunit/phpunit": "^11.5.3 || ^12.1.3"
},
"suggest": {
"cakephp/bake": "If you want to generate migrations.",
Expand All @@ -53,7 +52,9 @@
"Migrator\\": "tests/test_app/Plugin/Migrator/src/",
"SimpleSnapshot\\": "tests/test_app/Plugin/SimpleSnapshot/src/",
"TestApp\\": "tests/test_app/App/",
"TestBlog\\": "tests/test_app/Plugin/TestBlog/src/"
"TestBlog\\": "tests/test_app/Plugin/TestBlog/src/",
"Blog\\": "tests/test_app/Plugin/Blog/src/",
"Migrator\\": "tests/test_app/Plugin/Migrator/src/"
}
},
"config": {
Expand All @@ -67,8 +68,8 @@
"@stan",
"@test"
],
"cs-check": "phpcs -p",
"cs-fix": "phpcbf -p",
"cs-check": "phpcs --parallel=16 -p",
"cs-fix": "phpcbf --parallel=16 -p",
"phpstan": "tools/phpstan analyse",
"stan": "@phpstan",
"stan-baseline": "tools/phpstan --generate-baseline",
Expand Down
6 changes: 3 additions & 3 deletions config/app.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

return [
'Migrations' => [
'backend' => 'builtin',
'unsigned_primary_keys' => null,
'column_null_default' => null,
'unsigned_primary_keys' => null, // Default false
'unsigned_ints' => null, // Default false, make sure this is aligned with the above config
'column_null_default' => null, // Default false
],
];
75 changes: 67 additions & 8 deletions docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Migrations

Migrations is a plugin that lets you track changes to your database schema over
time as PHP code that accompanies your application. This lets you ensure each
environment your application runs in can has the appropriate schema by applying
environment your application runs in has the appropriate schema by applying
migrations.

Instead of writing schema modifications in SQL, this plugin allows you to
Expand Down Expand Up @@ -43,6 +43,12 @@ your application in your **config/app.php** file as explained in the `Database
Configuration section
<https://book.cakephp.org/5/en/orm/database-basics.html#database-configuration>`__.

Upgrading from 4.x
==================

If you are upgrading from Migrations 4.x, please see the :doc:`upgrading` guide
for breaking changes and migration steps.

Overview
========

Expand Down Expand Up @@ -218,7 +224,7 @@ also edit the migration after generation to add or customize the columns

Columns on the command line follow the following pattern::

fieldName:fieldType?[length]:indexType:indexName
fieldName:fieldType?[length]:default[value]:indexType:indexName

For instance, the following are all valid ways of specifying an email field:

Expand All @@ -238,6 +244,16 @@ Columns with a question mark after the fieldType will make the column nullable.

The ``length`` part is optional and should always be written between bracket.

The ``default[value]`` part is optional and sets the default value for the column.
Supported value types include:

* Booleans: ``true`` or ``false`` - e.g., ``active:boolean:default[true]``
* Integers: ``0``, ``123``, ``-456`` - e.g., ``count:integer:default[0]``
* Floats: ``1.5``, ``-2.75`` - e.g., ``rate:decimal:default[1.5]``
* Strings: ``'hello'`` or ``"world"`` (quoted) - e.g., ``status:string:default['pending']``
* Null: ``null`` or ``NULL`` - e.g., ``description:text?:default[null]``
* SQL expressions: ``CURRENT_TIMESTAMP`` - e.g., ``created_at:datetime:default[CURRENT_TIMESTAMP]``

Fields named ``created`` and ``modified``, as well as any field with a ``_at``
suffix, will automatically be set to the type ``datetime``.

Expand Down Expand Up @@ -318,6 +334,39 @@ will generate::
}
}

Adding a column with a default value
-------------------------------------

You can specify default values for columns using the ``default[value]`` syntax:

.. code-block:: bash

bin/cake bake migration AddActiveToUsers active:boolean:default[true]

will generate::

<?php
use Migrations\BaseMigration;

class AddActiveToUsers extends BaseMigration
{
public function change(): void
{
$table = $this->table('users');
$table->addColumn('active', 'boolean', [
'default' => true,
'null' => false,
]);
$table->update();
}
}

You can combine default values with other options like nullable and indexes:

.. code-block:: bash

bin/cake bake migration AddStatusToOrders status:string:default['pending']:unique

Altering a column
-----------------

Expand Down Expand Up @@ -419,8 +468,8 @@ for use in unit tests), you can use the ``--generate-only`` flag:

bin/cake bake migration_snapshot Initial --generate-only

This will create the migration file but will not add an entry to the phinxlog
table, allowing you to move the file to a different location without causing
This will create the migration file but will not add an entry to the migrations
tracking table, allowing you to move the file to a different location without causing
"MISSING" status issues.

The same logic will be applied implicitly if you wish to bake a snapshot for a
Expand Down Expand Up @@ -554,15 +603,15 @@ Cleaning up missing migrations
-------------------------------

Sometimes migration files may be deleted from the filesystem but still exist
in the phinxlog table. These migrations will be marked as **MISSING** in the
status output. You can remove these entries from the phinxlog table using the
in the migrations tracking table. These migrations will be marked as **MISSING** in the
status output. You can remove these entries from the tracking table using the
``--cleanup`` option:

.. code-block:: bash

bin/cake migrations status --cleanup

This will remove all migration entries from the phinxlog table that no longer
This will remove all migration entries from the tracking table that no longer
have corresponding migration files in the filesystem.

Marking a migration as migrated
Expand Down Expand Up @@ -795,9 +844,10 @@ pass them to the method::
Feature Flags
=============

Migrations offers a few feature flags to compatibility with phinx. These features are disabled by default but can be enabled if required:
Migrations offers a few feature flags for compatibility. These features are disabled by default but can be enabled if required:

* ``unsigned_primary_keys``: Should Migrations create primary keys as unsigned integers? (default: ``false``)
* ``unsigned_ints``: Should Migrations create all integer columns as unsigned? (default: ``false``)
* ``column_null_default``: Should Migrations create columns as null by default? (default: ``false``)
* ``add_timestamps_use_datetime``: Should Migrations use ``DATETIME`` type
columns for the columns added by ``addTimestamps()``.
Expand All @@ -806,9 +856,18 @@ Set them via Configure to enable (e.g. in ``config/app.php``)::

'Migrations' => [
'unsigned_primary_keys' => true,
'unsigned_ints' => true,
'column_null_default' => true,
],

.. note::

The ``unsigned_primary_keys`` and ``unsigned_ints`` options only affect MySQL databases.
When generating migrations with ``bake migration_snapshot`` or ``bake migration_diff``,
the ``signed`` attribute will only be included in the output for unsigned columns
(as ``'signed' => false``). Signed is the default for integer columns in MySQL, so
``'signed' => true`` is never output.

Skipping the ``schema.lock`` file generation
============================================

Expand Down
Loading