Skip to content

Commit

Permalink
Add docs on the intended upgrade process.
Browse files Browse the repository at this point in the history
I'll continue to expand this as necessary with new findings.
  • Loading branch information
markstory committed Apr 4, 2024
1 parent b7aba37 commit 0fbb0b5
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/en/contents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
:caption: CakePHP Migrations

/index
/upgrading-to-builtin-backend
57 changes: 57 additions & 0 deletions docs/en/upgrading-to-builtin-backend.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Upgrading to the builtin backend
################################

As of migrations XXX there is a new migrations backend that uses CakePHP's
database abstractions and ORM. Longer term this will allow for phinx to be
removed as a dependency. This greatly reduces the dependency footprint of
migrations.

What is the same?
=================

Your migrations shouldn't have to change much to adapt to the new backend.
The migrations backend implements all of the phinx interfaces and can run
migrations based on phinx classes. If your migrations don't work in a way that
could be addressed by the changes outlined below, please open an issue, as we'd
like to maintain as much compatibility as we can.

What is different?
==================

If your migrations are using the ``AdapterInterface`` to fetch rows or update
rows you will need to update your code. If you use ``Adapter::query()`` to
execute queries, the return of this method is now
``Cake\Database\StatementInterface`` instead. This impacts ``fetchAll()``,
and ``fetch()``::

// This
$stmt = $this->getAdapter()->query('SELECT * FROM articles');
$rows = $stmt->fetchAll();

// Now needs to be
$stmt = $this->getAdapter()->query('SELECT * FROM articles');
$rows = $stmt->fetchAll('assoc');

Similar changes are for fetching a single row::

// This
$stmt = $this->getAdapter()->query('SELECT * FROM articles');
$rows = $stmt->fetch();

// Now needs to be
$stmt = $this->getAdapter()->query('SELECT * FROM articles');
$rows = $stmt->fetch('assoc');

Enabling the new backend
========================

The new backend can be enabled through application configuration. Add the
following to your ``config/app.php``::

return [
// Other configuration.
'Migrations' => ['backend' => 'builtin'],
];

If your migrations have problems running with the builtin backend, removing this
configuration option will revert to using phinx.

0 comments on commit 0fbb0b5

Please sign in to comment.