Migrate specific table/migration file in Laravel
Sometimes we need to migrate only a specific table/migration file but our command is for all migrations. We can use the
php artisan migrate command to migrate specific file with particular command flags.
Create the migration file
First of all, let’s create a migration file with the below given artisan command.
php artisan make:migration create_example_table
It will add the new migration file to the
database/migrations directory. Now we want to run this specific migration.
Example of migrate specific migration file
If we just use the
php artisan migrate command then it will run all the migrations in the path
database/migrations. So, we have to run the migrate command on a specific path with the migration file name included.
php artisan migrate –path=/database/migration/dateString_create_tableName_table.php
As we can see in the above artisan command, we just need to declare the
–path for the migration. Then It will only find one migration and migrate it successfully.
Hope you found it useful. See you in the next quick help.