Skip to content

docs: [Migration] clarify that $db is for testing purposes #8222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 4 additions & 7 deletions system/Database/MigrationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,11 @@ class MigrationRunner
protected $groupSkip = false;

/**
* Constructor.
* The migration can manage multiple databases. So it should always use the
* default DB group so that it creates the `migrations` table in the default
* DB group. Therefore, passing $db is for testing purposes only.
*
* When passing in $db, you may pass any of the following to connect:
* - group name
* - existing connection instance
* - array of database configuration values
*
* @param array|ConnectionInterface|string|null $db
* @param array|ConnectionInterface|string|null $db DB group. For testing purposes only.
Copy link
Member

Choose a reason for hiding this comment

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

Interesting that @internal can be used inline: https://docs.phpdoc.org/2.9/references/phpdoc/inline-tags/internal.html

I wonder if any static analyzers would enforce this on a parameter?

Suggested change
* @param array|ConnectionInterface|string|null $db DB group. For testing purposes only.
* @param array|ConnectionInterface|string|null $db DB group. {@internal For testing purposes only.}

*
* @throws ConfigException
*/
Expand Down
5 changes: 4 additions & 1 deletion user_guide_src/source/dbmgmt/migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Database Groups
===============

A migration will only be run against a single database group. If you have multiple groups defined in
**app/Config/Database.php**, then it will run against the ``$defaultGroup`` as specified
**app/Config/Database.php**, then by default it will run against the ``$defaultGroup`` as specified
in that same configuration file.

There may be times when you need different schemas for different
Expand All @@ -79,6 +79,9 @@ match the name of the database group exactly:

.. literalinclude:: migration/003.php

.. note:: The **migrations** table that tracks which migrations have already been
run will be always created in the default database group.

Namespaces
==========

Expand Down