How can I run specific migration in laravel

PhpLaravel

Php Problem Overview


I create on address table migration but one migration is already in the database it gives following error :

>Base table or view already exists: 1050 Table 'notification' already exists

So, Can I run specific migration? How can I run in Laravel?

Php Solutions


Solution 1 - Php

TLDR;

"By the book":

If there are already migrated tables and there is some data stored in those tables, be careful with php artisan migrate:refresh. You will lose all your data!

For this specific question OP has already run the migration and by the book if he wants to run the same migration again, then first he should rollback with php artisan migrate:rollback. This will undo the last migration/s.

Then you can run php artisan migrate and all NOT migrated migrations will be migrated.


If you created more migrations and they are not migrated yet, to run only a specific migration use this:

php artisan migrate --path=/database/migrations/full_migration_file_name_migration.php

And sometimes if there is something messed up and you get errors on migrate, saying that the table already exists you can manually delete that specific entry from migrations AND the table which causes the problem in your DB and run php artisan:migrate to recreate the table.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKeval MangukiyaView Question on Stackoverflow
Solution 1 - PhpRavi ThummarView Answer on Stackoverflow