-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docs on the intended upgrade process.
I'll continue to expand this as necessary with new findings.
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
:caption: CakePHP Migrations | ||
|
||
/index | ||
/upgrading-to-builtin-backend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |