Skip to content

Commit 647f4e7

Browse files
authored
Merge pull request #9179 from kenjis/improve-migration-file-names
docs: improve "Migration File Names"
2 parents 0a6b39d + e53c32c commit 647f4e7

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

user_guide_src/source/dbmgmt/migration.rst

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,28 @@ include migrations from all namespaces.
2222
Migration File Names
2323
********************
2424

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

30-
Prefix your migration files with the migration number followed by an underscore
31-
and a descriptive name for the migration. The year, month, and date can be separated
32-
from each other by dashes, underscores, or not at all. For example:
33+
The descriptive name (**AddBlogTable**) for the migration is a classname in PHP.
34+
So you must name a valid classname.
35+
36+
The year, month, day, and time in a prefix can be separated from each other by
37+
dashes (``-``), underscores (``_``), or not at all. For example:
3338

3439
* 2012-10-31-100538_AlterBlogTrackViews.php
3540
* 2012_10_31_100539_AlterBlogAddTranslations.php
3641
* 20121031100537_AddBlog.php
3742

43+
Each Migration is run in numeric order forward or backwards depending on the
44+
method taken. This helps prevent numbering conflicts when working in a team
45+
environment.
46+
3847
******************
3948
Create a Migration
4049
******************
@@ -49,7 +58,7 @@ The database connection and the database Forge class are both available to you t
4958
``$this->db`` and ``$this->forge``, respectively.
5059

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

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

0 commit comments

Comments
 (0)