Generate Migrations

In VaahCms to generate Migrations follow the steps provided below:

step 1:

Generate migrations with the help of VaahCLI by clicking here


Run the below command

 npx vaah cms:m-make migration <module-name> <migration-name>


npx vaah cms:m-make migration Sample sp_products

step 2:

This will generate a migration file at VaahCms/Modules/Sample/Database/Migrations/. You can make changes to this file acording to your database schema needs.

Let's edit the migration file to following:


use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class SpProducts extends Migration
     * Run the migrations.
     * @return void
    public function up()

        Schema::create('sp_products', function (Blueprint $table) {
            //----common fields
            $table->index(['created_at', 'updated_at', 'deleted_at']);
            //----/common fields


    * Reverse the migrations.
    * @return void
    public function down()

step 3:

Now you need to run the migrations by visiting the following url


List of all the modules will be displayed. From this list, find your module and click on Actions button present on the right side of that same module to run the migrations.
Follow below image for reference: migration

step 4:

Now you need to click on Run Migrations button out of three options available to you.
Follow below image for reference: run the migrations

The table will be created and will be added to the database tables's list.
Follow below image for reference: products-table

Copyright © 2024