To run a specific migration file for table in Laravel, simply open your CMD or terminal window and type the
PHP artisan migrate command, along with specifying the
--path to the file for which you want to run the migration.
How to Run Specific Migration File in Laravel?
Steps to Migration specific file for specific table in laravel apps:
Step 1: Understand Database Migrations in Laravel
Before using any migration command in Laravel, get to know about that command. Because the migration command in Laravel directly modifies your database tables using the database schema.
Step 2: See Available Migrations
Now, open your terminal or command prompt and go to your Laravel project root directory. Then execute php artisan to see the list of available commands related to migration.
php artisan migrate:status
Step 3: Run Specific Migration File
To run migration for specific files to create specific tables in Laravel apps, Just open your cmd or terminal and type
php artisan migrate --path=path/to/migration/file.php for that:
php artisan migrate --path=path/to/migration/file.php
Note:- Please replace
path/to/migration/file.php with the actual path to your migration file.
Step 4: Verify Specific Migration
Once you have executed the above migration command, you should be able to see the result displayed on your terminal or cmd. Another option is that you can verify its execution by checking the database for any changes specified in the migration file.
That’s it; In this tutorial, you have learned how to migrate specific migration files for tables in Laravel apps.