From 998eb53916d6d985a2452e7daec934956bc11bdd Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 13 Jul 2023 10:55:50 +0900 Subject: [PATCH 1/4] docs: remove Migrate controller sample It is not recommended to use a controller for migration. Using CLI is recommended. --- user_guide_src/source/dbmgmt/migration.rst | 17 ++++------------ .../source/dbmgmt/migration/005.php | 20 ------------------- 2 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 user_guide_src/source/dbmgmt/migration/005.php diff --git a/user_guide_src/source/dbmgmt/migration.rst b/user_guide_src/source/dbmgmt/migration.rst index 616f782dce01..197e42d4a557 100644 --- a/user_guide_src/source/dbmgmt/migration.rst +++ b/user_guide_src/source/dbmgmt/migration.rst @@ -9,9 +9,9 @@ need to go and run them. You would also have to keep track of which changes need to be run against the production machines next time you deploy. The database table **migrations** tracks which migrations have already been -run so all you have to do is make sure your migrations are in place and -call ``$migration->latest()`` to bring the database up to the most recent -state. You can also use ``$migration->setNamespace(null)->latest()`` to +run, so all you have to do is make sure your migrations are in place and +run the ``spark migrate`` command to bring the database up to the most recent +state. You can also use ``spark migrate --all`` to include migrations from all namespaces. .. contents:: @@ -94,15 +94,6 @@ This will look for any migrations located at both **APPPATH/Database/Migrations* **ROOTPATH/MyCompany/Database/Migrations**. This makes it simple to include migrations in your re-usable, modular code suites. -************* -Usage Example -************* - -In this example some simple code is placed in **app/Controllers/Migrate.php** -to update the schema: - -.. literalinclude:: migration/005.php - .. _command-line-tools: ******************* @@ -110,7 +101,7 @@ Command-Line Tools ******************* CodeIgniter ships with several :doc:`commands ` that are available from the command line to help -you work with migrations. These tools are not required to use migrations but might make things easier for those of you +you work with migrations. These tools make things easier for those of you that wish to use them. The tools primarily provide access to the same methods that are available within the MigrationRunner class. migrate diff --git a/user_guide_src/source/dbmgmt/migration/005.php b/user_guide_src/source/dbmgmt/migration/005.php deleted file mode 100644 index e9b4c2ad37fe..000000000000 --- a/user_guide_src/source/dbmgmt/migration/005.php +++ /dev/null @@ -1,20 +0,0 @@ -latest(); - } catch (Throwable $e) { - // Do something with the error here... - } - } -} From f203918d7776777d8b8c44e19ad7c95aa9de41c1 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 13 Jul 2023 10:58:57 +0900 Subject: [PATCH 2/4] docs: add "..." to command output --- user_guide_src/source/dbmgmt/migration.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/user_guide_src/source/dbmgmt/migration.rst b/user_guide_src/source/dbmgmt/migration.rst index 197e42d4a557..59fad21b2415 100644 --- a/user_guide_src/source/dbmgmt/migration.rst +++ b/user_guide_src/source/dbmgmt/migration.rst @@ -162,6 +162,9 @@ status Displays a list of all migrations and the date and time they ran, or '--' if they have not been run:: > php spark migrate:status + + ... + +----------------------+-------------------+-----------------------+---------+---------------------+-------+ | Namespace | Version | Filename | Group | Migrated On | Batch | +----------------------+-------------------+-----------------------+---------+---------------------+-------+ From 5624e4bf37df08eec87817127cfd48a123a29d43 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 13 Jul 2023 10:59:15 +0900 Subject: [PATCH 3/4] docs: separate options for database sessions --- user_guide_src/source/dbmgmt/migration.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/dbmgmt/migration.rst b/user_guide_src/source/dbmgmt/migration.rst index 59fad21b2415..4a2f6229335f 100644 --- a/user_guide_src/source/dbmgmt/migration.rst +++ b/user_guide_src/source/dbmgmt/migration.rst @@ -188,13 +188,17 @@ creates is the Pascal case version of the filename. > php spark make:migration [options] -You can use (make:migration) with the following options: +You can use (``make:migration``) with the following options: + +- ``--namespace`` - Set root namespace. Default: ``APP_NAMESPACE``. +- ``--suffix`` - Append the component title to the class name. + +The following options are also available to generate the migration file for +database sessions: - ``--session`` - Generates the migration file for database sessions. - ``--table`` - Table name to use for database sessions. Default: ``ci_sessions``. - ``--dbgroup`` - Database group to use for database sessions. Default: ``default``. -- ``--namespace`` - Set root namespace. Default: ``APP_NAMESPACE``. -- ``--suffix`` - Append the component title to the class name. ********************* Migration Preferences From a634472b22298023cefe1a45016849d76514bc75 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 13 Jul 2023 11:01:35 +0900 Subject: [PATCH 4/4] docs: fix text decoration --- user_guide_src/source/dbmgmt/migration.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/dbmgmt/migration.rst b/user_guide_src/source/dbmgmt/migration.rst index 4a2f6229335f..ccb2827e9947 100644 --- a/user_guide_src/source/dbmgmt/migration.rst +++ b/user_guide_src/source/dbmgmt/migration.rst @@ -227,7 +227,7 @@ Class Reference :returns: An array of migration files :rtype: array - An array of migration filenames are returned that are found in the **path** property. + An array of migration filenames are returned that are found in the ``path`` property. .. php:method:: latest($group) @@ -257,7 +257,7 @@ Class Reference :returns: ``true`` on success, ``false`` on failure :rtype: bool - 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. + 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. .. note:: This method is recommended only for testing and could cause data consistency issues.