Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to re-migrate a laravel migration after deleting the table

Tags:

php

laravel

after I've manually deleted a table in mysql, I run the command:

php artisan migrate

and I get this:

Nothing to migrate.

it only works the first time, how to re-run the migration in laravel?

like image 982
Skrudox Avatar asked Jun 13 '18 12:06

Skrudox


People also ask

Can I delete a migration in Laravel?

Manually delete the migration file under app/database/migrations/my_migration_file_name. php. Reset the composer autoload files: composer dump-autoload. Modify your database: Remove the last entry from the migrations table.


2 Answers

Laravel keeps a record of migrations that have been run. You need to go to the migrations table and delete the migration record. Laravel does this so that it knows which migrations have been run so that it doesn't run them again and so that in the case of a rollback, it knows the last batch of migrations which were done.

This may help https://laravel.com/docs/5.6/migrations

like image 193
Leo Rams Avatar answered Sep 17 '22 18:09

Leo Rams


Try composer dump-autoload AND php artisan config:cache

if not working also Try php artisan migrate:refresh.

OR Also Delete Migration table in database.

like image 40
Sujal Patel Avatar answered Sep 20 '22 18:09

Sujal Patel