1

I created few migrations and migrated them, after that I deleted them manually without rolling back. and now I want to rollback other migrations but I'm getting an error that migration not found referring to the last migration I had deleted, even when I rollback a specefic migration with a --path I still get

migration not found: name_of_the_last_migration_I deleted_manually

with referring the last migration I deleted manually.

Dr.Noob
  • 319
  • 6
  • 17
  • 1
    Hi, try reading this question here on Stack, I think it can help you :-) [link](https://stackoverflow.com/questions/30287896/rollback-one-specific-migration-in-laravel) – 64Bit1990 Oct 05 '21 at 09:25

1 Answers1

3

The migrations are stored to a table (called "migrations") in your database. When you run a migration, it is added to that table - using the rollback function looks at the latest migration in the table and runs the down() function for it.

If you reverse a migration manually (ie. deleting the table or columns that the migration created) but then try to use the rollback function, it will fail because the migration cannot remove columns / tables that have already been removed.

So the answer is to delete the migration(s) that you have reversed from the migrations table.

Giles Bennett
  • 1,509
  • 1
  • 12
  • 15