Migrations and Seeds

# Generate Migrations

Let's assume there is only one table required for this module which is art_articles, here art is prefix for the module, so if you need to create more tables, you should always use prefix for all the tables to determine which table belongs to which module.

To generate migration use following command:

vaah cms:m-make migration Articles art_articles

This will generate a migration file at VaahCms/Modules/Articles/Database/Migrations/. Let's edit the migration file to following:

copy
# Setup Seeds

Seeds are used to generate necessary data or sample data for the module. At VaahCms/Modules/Articles/Database/Seeds folder you will find two files:

  • DatabaseTableSeeder.php: This seeder file will be called whenever you will activate the module from the backend of the VaahCMS.
  • SampleDataTableSeeder.php: This seeder file will be called whenever you will click on "Import Sample Data" button of the module.

In this tutorial, let's assume that we want to add 15 articles by default whenever the module is activated, hence we'll be editing DatabaseTableSeeder.php file.

copy