Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5192cc3
Add unified cake_migrations table support with BC autodetect
dereuromark Nov 22, 2025
690b078
Address PR feedback for unified migrations table
dereuromark Nov 23, 2025
79ec7d4
Use hasTable() for phinxlog detection
dereuromark Nov 23, 2025
e35f3e4
Add CI matrix, tests, docs for unified migrations table
dereuromark Nov 23, 2025
a034f31
Remove development notes
dereuromark Nov 23, 2025
d756e1f
Merge branch '5.x' into 5.x-unified-migrations-table
dereuromark Nov 23, 2025
329ee61
Hide upgrade command when legacyTables is false
dereuromark Nov 23, 2025
f23bef2
Remove LEGACY_TABLES CI matrix, partial test fixes
dereuromark Nov 23, 2025
c0ca79a
Cleanup.
dereuromark Nov 23, 2025
e69cc8f
Update tests to support unified migrations table mode
dereuromark Nov 23, 2025
42f498f
Remove undefined resetOutput() call from StatusCommandTest
dereuromark Nov 23, 2025
84528b6
Fix test suite for LEGACY_TABLES=false CI build
dereuromark Nov 24, 2025
7b9be94
Update src/Command/MigrationsUpgradeCommand.php
dereuromark Nov 29, 2025
ab0af12
Update src/Command/MigrationsUpgradeCommand.php
dereuromark Nov 29, 2025
b1b795c
Update docs/en/upgrading-to-builtin-backend.rst
dereuromark Nov 29, 2025
dc48661
Update docs/en/upgrading-to-builtin-backend.rst
dereuromark Nov 29, 2025
6fc996b
Update docs/en/upgrading-to-builtin-backend.rst
dereuromark Nov 29, 2025
c1fc1b9
Update src/Command/MigrationsUpgradeCommand.php
dereuromark Nov 29, 2025
7643c3b
Update src/Db/Adapter/AbstractAdapter.php
dereuromark Nov 29, 2025
62738aa
Feedback and fixes
markstory Dec 3, 2025
0c3406c
Merge branch '5.x' into 5.x-unified-migrations-table
dereuromark Dec 3, 2025
62ca3fe
Add more tests.
dereuromark Dec 4, 2025
f53fcdd
Move files around and add tests
markstory Dec 5, 2025
567aaa5
Add loadbearing gitkeep file.
markstory Dec 6, 2025
d38c20e
See if this test is causing CI to fail and emit warnings.
markstory Dec 6, 2025
6e09f62
Narrow type with assert()
markstory Dec 6, 2025
2f27c91
Unskip test, it was the problem after all.
markstory Dec 6, 2025
6b4ffb7
Fix quotes
markstory Dec 6, 2025
8fe27e2
Add another directory.
markstory Dec 6, 2025
65a7323
Fix diff baking tests to delete migration file after running migrate.
dereuromark Dec 7, 2025
7e6b59c
Remove file.
dereuromark Dec 7, 2025
96883d1
Auto create folder. ensures a more stable setup.
dereuromark Dec 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
php-version: ['8.2', '8.5']
db-type: [mariadb, mysql, pgsql, sqlite]
prefer-lowest: ['']
legacy-tables: ['']
include:
- php-version: '8.2'
db-type: 'sqlite'
Expand All @@ -32,6 +33,10 @@ jobs:
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 @@ -135,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 Down
89 changes: 89 additions & 0 deletions docs/en/upgrading-to-builtin-backend.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,95 @@ Similar changes are for fetching a single row::
$stmt = $this->getAdapter()->query('SELECT * FROM articles');
$rows = $stmt->fetch('assoc');

Unified Migrations Table
========================

As of migrations 5.x, there is a new unified ``cake_migrations`` table that
replaces the legacy ``phinxlog`` tables. This provides several benefits:

- **Single table for all migrations**: Instead of separate ``phinxlog`` (app)
and ``{plugin}_phinxlog`` (plugins) tables, all migrations are tracked in
one ``cake_migrations`` table with a ``plugin`` column.
- **Simpler database schema**: Fewer migration tracking tables to manage.
- **Better plugin support**: Plugin migrations are properly namespaced.

Backward Compatibility
----------------------

For existing applications with ``phinxlog`` tables:

- **Automatic detection**: If any ``phinxlog`` table exists, migrations will
continue using the legacy tables automatically.
- **No forced migration**: Existing applications don't need to change anything.
- **Opt-in upgrade**: You can migrate to the new table when you're ready.

Configuration
-------------

The ``Migrations.legacyTables`` configuration option controls the behavior:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
The ``Migrations.legacyTables`` configuration option controls the behavior:
The ``Migrations.phinxTables`` configuration option controls the behavior:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Doesnt this kind of confuse people? Why would people want to upgrade if both sound equal.
The legacy wording makes the upgrade path clear towards 6.x (no phinxlog at all).
This sounds like they have no need to, and as such would stay on the old path forwever.


.. code-block:: php

// config/app.php or config/app_local.php
'Migrations' => [
// null (default): Autodetect - use legacy if phinxlog tables exist
// false: Force use of new cake_migrations table
// true: Force use of legacy phinxlog tables
'legacyTables' => null,
],

Upgrading to the Unified Table
------------------------------

To migrate from ``phinxlog`` tables to the new ``cake_migrations`` table:

1. **Preview the upgrade** (dry run):

.. code-block:: bash

bin/cake migrations upgrade --dry-run

2. **Run the upgrade**:

.. code-block:: bash

bin/cake migrations upgrade

3. **Update your configuration**:

.. code-block:: php

// config/app.php
'Migrations' => [
'legacyTables' => false,
],

4. **Optionally drop phinx tables**: Your migration history is preserved
by default. Use ``--drop-tables`` to drop the ``phinxlog``tables after
verifying your migrations run correctly.

.. code-block:: bash

bin/cake migrations upgrade --drop-tables

Rolling Back
------------

If you need to revert to phinx tables after upgrading:

1. Set ``'legacyTables' => true`` in your configuration.

.. warning::

You cannot rollback after running ``upgrade --drop-tables``.


New Installations
-----------------

For new applications without any existing ``phinxlog`` tables, the unified
``cake_migrations`` table is used automatically. No configuration is needed.

Problems with the builtin backend?
==================================

Expand Down
3 changes: 3 additions & 0 deletions src/Command/BakeMigrationDiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,9 @@ protected function getCurrentSchema(): array
if (preg_match('/^.*phinxlog$/', $table) === 1) {
continue;
}
if ($table === 'cake_migrations' || $table === 'cake_seeds') {
continue;
}

$schema[$table] = $collection->describe($table);
}
Expand Down
Loading