"Hello developers,
I have an issue with 4 migrations that are not found. Please let me know if there's any way to delete these migrations. I checked the migration files but couldn't find them in the migration directory. I've tried many approaches but none have worked.
Could you please advise on how to delete these problematic migrations?
2025_01_13_215047_create_companies_table .................................................................. Migration not found
2025_01_11_223243_create_tag_tables ....................................................................... Migration not found
2025_01_11_223243_create_filament_blog_tables ............................................................. Migration not found
2025_01_07_235926_create_about_us_table ................................................................... Migration not found
If you check the migrations table, you will find those migrations there, and that's what's causing the issue. Deleting them will solve it, but you need to be careful because those tables still exist in the database. However, their migrations are gone, so anytime you deploy the project, it will fail.
I have 4 migrations that Laravel says are 'not found'. However, 2 of these migrations have the same name as migrations I created before. I deleted the original migrations a long time ago, but later I created 2 new migrations using the same names as before.
Now when I try to run migrations, Laravel says 'table already exists' because it's detecting the old migrations that were already run on the database. When I push to the server, I get errors.
The tables exist in the database, but I only have one migration file for each name in my codebase now. I can see all the old migrations in the migrations table, but when I try to delete them, I still get the same error. How can I fix this so Laravel stops looking for the old migrations that don't exist anymore?
What operation were you attempting? Are these migration files recorded in the migrations table in your database; if so and you manually deleted the files, then simply deleting the relevant migration table records should work.
@tykus I have 4 migrations that Laravel says are 'not found'. However, 2 of these migrations have the same name as migrations I created before. I deleted the original migrations a long time ago, but later I created 2 new migrations using the same names as before.
Now when I try to run migrations, Laravel says 'table already exists' because it's detecting the old migrations that were already run on the database. When I push to the server, I get errors.
The tables exist in the database, but I only have one migration file for each name in my codebase now. I can see all the old migrations in the migrations table, but when I try to delete them, I still get the same error. How can I fix this so Laravel stops looking for the old migrations that don't exist anymore?
Yes, it's not the same timestamp. I tried to delete by timestamp, but it didn't work. I don't know how to fix it, really. I asked ChatGPT, but it also didn't work.
A long time ago, I ran this command, which seems to have determined the old migrations. After deleting the schema file in the migrations folder, everything worked. Thanks!"
@ayub01zero Why are you deleting migration files after they’ve been applied to your database in the first place? 😬
You should never change or delete migrations after they have been ran. Otherwise your project and database ends up in an inconsistent state, like you have found.
php artisan migrate:fresh will re-instantiate the migration table and then run the migrations.
As for your question, you can edit the migrations table in your database and delete those that you got an error. However, the above command is the preferred approach. You can also add a --seed option at the end.