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
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:
- How to Select Data Between Two Dates in MySQL
- Error After php artisan config:cache In Laravel
- Specified Key Was Too Long Error In Laravel
- AJAX PHP Post Request With Example
- How To Use The Laravel Soft Delete
- How To Add Laravel Next Prev Pagination
- Laravel Remove Column From Table In Migration
- Difference Between Factory And Seeders In Laravel
- Laravel: Increase Quantity If Product Already Exists In Cart
- How To Calculate Age From Birthdate
- How To Check Laravel PHP Version
- How To Handle Failed Jobs In Laravel
- How To Remove WooCommerce Data After Uninstall
- How To Get Latest Records In Laravel
- How To Break Nested Loops In PHP Or Laravel
- 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!