Skip to content
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

docs: improve "Migration File Names" #9179

Merged
merged 3 commits into from
Sep 9, 2024
Merged
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
25 changes: 17 additions & 8 deletions user_guide_src/source/dbmgmt/migration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,28 @@ include migrations from all namespaces.
Migration File Names
********************

Each Migration is run in numeric order forward or backwards depending on the
method taken. Each migration is numbered using the timestamp when the migration
was created, in **YYYY-MM-DD-HHIISS** format (e.g., **2012-10-31-100537**). This
helps prevent numbering conflicts when working in a team environment.
A migration file name is made up of a timestamp prefix, an underscore (``_``),
and a descriptive name (classname).

* 2024-09-08-013653_AddBlogTable.php

Each migration is numbered using the timestamp (**2024-09-08-013653**) when the
migration was created, in **YYYY-MM-DD-HHIISS** format.

Prefix your migration files with the migration number followed by an underscore
and a descriptive name for the migration. The year, month, and date can be separated
from each other by dashes, underscores, or not at all. For example:
The descriptive name (**AddBlogTable**) for the migration is a classname in PHP.
So you must name a valid classname.

The year, month, day, and time in a prefix can be separated from each other by
dashes (``-``), underscores (``_``), or not at all. For example:

* 2012-10-31-100538_AlterBlogTrackViews.php
* 2012_10_31_100539_AlterBlogAddTranslations.php
* 20121031100537_AddBlog.php

Each Migration is run in numeric order forward or backwards depending on the
method taken. This helps prevent numbering conflicts when working in a team
environment.

******************
Create a Migration
******************
Expand All @@ -49,7 +58,7 @@ The database connection and the database Forge class are both available to you t
``$this->db`` and ``$this->forge``, respectively.

Alternatively, you can use a command-line call to generate a skeleton migration file.
See **make:migration** in :ref:`command-line-tools` for more details.
See `make:migration`_ in :ref:`command-line-tools` for more details.

.. note:: Since the migration class is a PHP class, the classname must be unique in every migration file.

Expand Down