Home » Laravel Run Specific Migration

Laravel Run Specific Migration

Last updated on May 29, 2021 by

In this article, we will see how to run specific migration in Laravel. Often, we face lots of troubles while doing the coding. Especially, when you are a beginner.

Sometimes, migration will be a pain when you have mistakenly added the faulty code and when you run migration then it will create only some of the tables and it will stop creating tables when it encountered an error in specific migration.

So let’s see how to solve errors and handle the migration in the Laravel.

Laravel Run Specific Migration

To run the specific migration in Laravel, you need to use --path option with the php artisan migrate command.

Let’s take a simple example, we have '2019_12_04_131405_create_payments_table.php' migration in the database/migrations directory and we would like to run this migration.

php artisan migrate --path=/database/migrations/2019_12_04_131405_create_payments_table.php

Create Migrations In Different Folder In Laravel

You can use the same --path option while creating migration and it will easily create the migration in the newly defined path as below:

php artisan migrate:make create_payments_table --path=app/migrations/payments

After running the above command new migration and directories will be created into the app/migrations/payments folder.

Run All Migrations In Different Folder In Laravel

As we have created new migration in a different folder than database/migrations then you can run all that migrations by using same --path option with php artisan migrate command as below:

php artisan migrate --path=app/migrations/payments

Additionally, read our guide:

  1. How to Select Data Between Two Dates in MySQL
  2. Error After php artisan config:cache In Laravel
  3. Specified Key Was Too Long Error In Laravel
  4. AJAX PHP Post Request With Example
  5. How To Use The Laravel Soft Delete
  6. How To Add Laravel Next Prev Pagination
  7. Laravel Remove Column From Table In Migration
  8. Difference Between Factory And Seeders In Laravel
  9. Laravel: Increase Quantity If Product Already Exists In Cart
  10. How To Calculate Age From Birthdate
  11. How To Check Laravel PHP Version
  12. How To Handle Failed Jobs In Laravel
  13. How To Remove WooCommerce Data After Uninstall
  14. How To Get Latest Records In Laravel
  15. How To Break Nested Loops In PHP Or Laravel
  16. How To Pass Laravel URL Parameter

That’s it from our end. We hope this article helped you to run specific migration in Laravel and run multiple migrations from different folder in Laravel.

Please let us know in the comments if everything worked as expected, your issues, or any questions. If you think this article saved your time & money, please do comment, share, like & subscribe. Thank you for reading this post 🙂 Keep Smiling! Happy Coding!


Leave a Comment