Skip to content

Commit 39e9a1d

Browse files
authored
Merge pull request #7700 from kenjis/docs-migration.rst
docs: improve migration.rst
2 parents cc61150 + a634472 commit 39e9a1d

2 files changed

Lines changed: 16 additions & 38 deletions

File tree

user_guide_src/source/dbmgmt/migration.rst

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ need to go and run them. You would also have to keep track of which changes
99
need to be run against the production machines next time you deploy.
1010

1111
The database table **migrations** tracks which migrations have already been
12-
run so all you have to do is make sure your migrations are in place and
13-
call ``$migration->latest()`` to bring the database up to the most recent
14-
state. You can also use ``$migration->setNamespace(null)->latest()`` to
12+
run, so all you have to do is make sure your migrations are in place and
13+
run the ``spark migrate`` command to bring the database up to the most recent
14+
state. You can also use ``spark migrate --all`` to
1515
include migrations from all namespaces.
1616

1717
.. contents::
@@ -94,23 +94,14 @@ This will look for any migrations located at both **APPPATH/Database/Migrations*
9494
**ROOTPATH/MyCompany/Database/Migrations**. This makes it simple to include migrations in your
9595
re-usable, modular code suites.
9696

97-
*************
98-
Usage Example
99-
*************
100-
101-
In this example some simple code is placed in **app/Controllers/Migrate.php**
102-
to update the schema:
103-
104-
.. literalinclude:: migration/005.php
105-
10697
.. _command-line-tools:
10798

10899
*******************
109100
Command-Line Tools
110101
*******************
111102

112103
CodeIgniter ships with several :doc:`commands </cli/spark_commands>` that are available from the command line to help
113-
you work with migrations. These tools are not required to use migrations but might make things easier for those of you
104+
you work with migrations. These tools make things easier for those of you
114105
that wish to use them. The tools primarily provide access to the same methods that are available within the MigrationRunner class.
115106

116107
migrate
@@ -171,6 +162,9 @@ status
171162
Displays a list of all migrations and the date and time they ran, or '--' if they have not been run::
172163

173164
> php spark migrate:status
165+
166+
...
167+
174168
+----------------------+-------------------+-----------------------+---------+---------------------+-------+
175169
| Namespace | Version | Filename | Group | Migrated On | Batch |
176170
+----------------------+-------------------+-----------------------+---------+---------------------+-------+
@@ -194,13 +188,17 @@ creates is the Pascal case version of the filename.
194188

195189
> php spark make:migration <class> [options]
196190

197-
You can use (make:migration) with the following options:
191+
You can use (``make:migration``) with the following options:
192+
193+
- ``--namespace`` - Set root namespace. Default: ``APP_NAMESPACE``.
194+
- ``--suffix`` - Append the component title to the class name.
195+
196+
The following options are also available to generate the migration file for
197+
database sessions:
198198

199199
- ``--session`` - Generates the migration file for database sessions.
200200
- ``--table`` - Table name to use for database sessions. Default: ``ci_sessions``.
201201
- ``--dbgroup`` - Database group to use for database sessions. Default: ``default``.
202-
- ``--namespace`` - Set root namespace. Default: ``APP_NAMESPACE``.
203-
- ``--suffix`` - Append the component title to the class name.
204202

205203
*********************
206204
Migration Preferences
@@ -229,7 +227,7 @@ Class Reference
229227
:returns: An array of migration files
230228
:rtype: array
231229

232-
An array of migration filenames are returned that are found in the **path** property.
230+
An array of migration filenames are returned that are found in the ``path`` property.
233231

234232
.. php:method:: latest($group)
235233
@@ -259,7 +257,7 @@ Class Reference
259257
:returns: ``true`` on success, ``false`` on failure
260258
:rtype: bool
261259

262-
This forces a single file to migrate regardless of order or batches. Method "up" or "down" is detected based on whether it has already been migrated.
260+
This forces a single file to migrate regardless of order or batches. Method ``up()`` or ``down()`` is detected based on whether it has already been migrated.
263261

264262
.. note:: This method is recommended only for testing and could cause data consistency issues.
265263

user_guide_src/source/dbmgmt/migration/005.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)