From 8a256a2f005466c14095cb02c2dea8a659b1a8a4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 21 Mar 2023 18:09:18 +0900 Subject: [PATCH 1/5] docs: fix section title level --- user_guide_src/source/dbmgmt/seeds.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/dbmgmt/seeds.rst b/user_guide_src/source/dbmgmt/seeds.rst index 9eb9ee4396f9..087011e2fd83 100644 --- a/user_guide_src/source/dbmgmt/seeds.rst +++ b/user_guide_src/source/dbmgmt/seeds.rst @@ -14,8 +14,9 @@ stored within the **app/Database/Seeds** directory. The name of the file must ma .. literalinclude:: seeds/001.php +*************** Nesting Seeders -=============== +*************** Seeders can call other seeders, with the **call()** method. This allows you to easily organize a central seeder, but organize the tasks into separate seeder files: @@ -27,23 +28,25 @@ anywhere the autoloader can find them. This is great for more modular code bases .. literalinclude:: seeds/003.php +************* Using Seeders -============= +************* You can grab a copy of the main seeder through the database config class: .. literalinclude:: seeds/004.php Command Line Seeding --------------------- +==================== You can also seed data from the command line, as part of the Migrations CLI tools, if you don't want to create a dedicated controller:: > php spark db:seed TestSeeder -Creating Seed Files -------------------- +********************* +Creating Seeder Files +********************* Using the command line, you can easily generate seed files. From 00abda1300116e55b60c205e8b6bbd939a882565 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 21 Mar 2023 18:09:53 +0900 Subject: [PATCH 2/5] docs: replace seeds with seeders For consistency. --- user_guide_src/source/dbmgmt/seeds.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/dbmgmt/seeds.rst b/user_guide_src/source/dbmgmt/seeds.rst index 087011e2fd83..fb21f3ff2e8e 100644 --- a/user_guide_src/source/dbmgmt/seeds.rst +++ b/user_guide_src/source/dbmgmt/seeds.rst @@ -4,10 +4,10 @@ Database Seeding Database seeding is a simple way to add data into your database. It is especially useful during development where you need to populate the database with sample data that you can develop against, but it is not limited to that. -Seeds can contain static data that you don't want to include in a migration, like countries, or geo-coding tables, +Seeders can contain static data that you don't want to include in a migration, like countries, or geo-coding tables, event or setting information, and more. -Database seeds are simple classes that must have a **run()** method, and extend ``CodeIgniter\Database\Seeder``. +Database seeders are simple classes that must have a **run()** method, and extend ``CodeIgniter\Database\Seeder``. Within the **run()** the class can create any form of data that it needs to. It has access to the database connection and the forge through ``$this->db`` and ``$this->forge``, respectively. Seed files must be stored within the **app/Database/Seeds** directory. The name of the file must match the name of the class. From 39af027fbf54d1a5ff05cb3df70e22649d35f9c7 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 21 Mar 2023 18:10:18 +0900 Subject: [PATCH 3/5] docs: add section title and TOC --- user_guide_src/source/dbmgmt/seeds.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/user_guide_src/source/dbmgmt/seeds.rst b/user_guide_src/source/dbmgmt/seeds.rst index fb21f3ff2e8e..bdf2ff28a5fa 100644 --- a/user_guide_src/source/dbmgmt/seeds.rst +++ b/user_guide_src/source/dbmgmt/seeds.rst @@ -7,6 +7,14 @@ you need to populate the database with sample data that you can develop against, Seeders can contain static data that you don't want to include in a migration, like countries, or geo-coding tables, event or setting information, and more. +.. contents:: + :local: + :depth: 2 + +**************** +Database Seeders +**************** + Database seeders are simple classes that must have a **run()** method, and extend ``CodeIgniter\Database\Seeder``. Within the **run()** the class can create any form of data that it needs to. It has access to the database connection and the forge through ``$this->db`` and ``$this->forge``, respectively. Seed files must be From f9cc308250f406f1525cddddce2e797cf0545113 Mon Sep 17 00:00:00 2001 From: kenjis Date: Tue, 21 Mar 2023 18:12:53 +0900 Subject: [PATCH 4/5] docs: change text decoration --- user_guide_src/source/dbmgmt/seeds.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/user_guide_src/source/dbmgmt/seeds.rst b/user_guide_src/source/dbmgmt/seeds.rst index bdf2ff28a5fa..7ea6ec2e310a 100644 --- a/user_guide_src/source/dbmgmt/seeds.rst +++ b/user_guide_src/source/dbmgmt/seeds.rst @@ -15,8 +15,8 @@ event or setting information, and more. Database Seeders **************** -Database seeders are simple classes that must have a **run()** method, and extend ``CodeIgniter\Database\Seeder``. -Within the **run()** the class can create any form of data that it needs to. It has access to the database +Database seeders are simple classes that must have a ``run()`` method, and extend ``CodeIgniter\Database\Seeder``. +Within the ``run()`` the class can create any form of data that it needs to. It has access to the database connection and the forge through ``$this->db`` and ``$this->forge``, respectively. Seed files must be stored within the **app/Database/Seeds** directory. The name of the file must match the name of the class. @@ -26,12 +26,12 @@ stored within the **app/Database/Seeds** directory. The name of the file must ma Nesting Seeders *************** -Seeders can call other seeders, with the **call()** method. This allows you to easily organize a central seeder, +Seeders can call other seeders, with the ``call()`` method. This allows you to easily organize a central seeder, but organize the tasks into separate seeder files: .. literalinclude:: seeds/002.php -You can also use a fully-qualified class name in the **call()** method, allowing you to keep your seeders +You can also use a fully-qualified class name in the ``call()`` method, allowing you to keep your seeders anywhere the autoloader can find them. This is great for more modular code bases: .. literalinclude:: seeds/003.php @@ -63,10 +63,10 @@ Using the command line, you can easily generate seed files. > php spark make:seeder user --suffix // Output: UserSeeder.php file located at app/Database/Seeds directory. -You can supply the **root** namespace where the seed file will be stored by supplying the ``--namespace`` option:: +You can supply the ``root`` namespace where the seed file will be stored by supplying the ``--namespace`` option:: > php spark make:seeder MySeeder --namespace Acme\\Blog -If ``Acme\Blog`` is mapped to ``app/Blog`` directory, then this command will generate ``MySeeder.php`` at ``app/Blog/Database/Seeds`` directory. +If ``Acme\Blog`` is mapped to **app/Blog** directory, then this command will generate **MySeeder.php** at **app/Blog/Database/Seeds** directory. Supplying the ``--force`` option will overwrite existing files in destination. From 47ef1cb487f64ced5266b93ec3c0b96b9e9b6e42 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 22 Mar 2023 09:05:21 +0900 Subject: [PATCH 5/5] docs: add sample command for Windows --- user_guide_src/source/dbmgmt/seeds.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/user_guide_src/source/dbmgmt/seeds.rst b/user_guide_src/source/dbmgmt/seeds.rst index 7ea6ec2e310a..a846705e56c8 100644 --- a/user_guide_src/source/dbmgmt/seeds.rst +++ b/user_guide_src/source/dbmgmt/seeds.rst @@ -65,8 +65,12 @@ Using the command line, you can easily generate seed files. You can supply the ``root`` namespace where the seed file will be stored by supplying the ``--namespace`` option:: + For Unix: > php spark make:seeder MySeeder --namespace Acme\\Blog + For Windows: + > php spark make:seeder MySeeder --namespace Acme\Blog + If ``Acme\Blog`` is mapped to **app/Blog** directory, then this command will generate **MySeeder.php** at **app/Blog/Database/Seeds** directory. Supplying the ``--force`` option will overwrite existing files in destination.