Laravel 14-Jul-2023

PHP artisan migrate specific migration

To migrate specific migration for tables in Laravel; In this tutorial, you will learn how to migrate specific migration files for tables in Laravel apps.

How to Migrate Specific Migration Files for Tables in Laravel

Using the following steps, you can migrate specific migration files for specific tables in laravel apps:

  • Step 1: Understand Database Migrations in Laravel
  • Step 2: See Available Migrations
  • Step 3: Run Specific Migration File
  • Step 4: Verify Specific Migration

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

If you want to migrate a specific migration file for a specific table in Laravel apps. So, open terminal or command prompt and execute the following command into it to migrate specific migration files in laravel apps:

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. And another option is that you can verify its execution by checking the database for any changes specified in the migration file.

Conclusion

That’s it; In this tutorial, you have learned how to migrate specific migration files for tables in Laravel apps.