Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

david001's avatar

How to delete migration file

Hi , I am using Laravel 6. I created one new migration file. I don't need it now so I deleted it from migration folder but when I run

php artisan migrate:fresh

or

php artisan migrate

Still I can see that particular table in my database. How can i delete it permanently .

Thank you

0 likes
8 replies
tykus's avatar

The table is still in the database because the down method was not run. Your migrations are a snapshot, they do not (and should not) maintain the current state of the schema without your direct running of php artisan migrate!

If you don't need the table (and the migration file already has been removed) then you can delete it in the database directly. Or create a new migration and in the up method dropIfExists the table:

public function up()
{
    Schema::dropIfExists('unwanted-table');
}
david001's avatar

i deleted directly from database table and i deleted same file from migration folder as well. Now i don't have that migration file but when i run php artisan migrate:fresh

it creates same table name again in database. I am suprised how it is happening even though i deleted migration file of that particular table

tykus's avatar

Are you creating more than one table in other migration files? It should be as simple as searching the migrations directory for the table name

tykus's avatar

If there is nothing in the migrations, then nothing should be created in the database; stuff doesn't just magic out of thin air...

fylzero's avatar

If I choose to delete a migration file... I remove all tables in the db then just migrate. Migrations are design to move forward and backward not really to remove things in the middle. If that makes sense.

24 likes
david001's avatar

I restarted server and tried again, now its fine. Thanks

tonybug's avatar

Sometimes it's better to avoid running migration in different environments, but instead of removing it from the codebase, it's better to make it empty. Your code can look like this:

<?php

use Abagayev\Laravel\MigrationShortcuts\Migrations\EmptyMigration;

class MyMigration extends EmptyMigration
{
    //
}

To make it work you need to install Laravel Migration Shortcuts package as well:

$ composer require abagayev/laravel-migration-shortcuts

You can read a bit more about the library itself here: https://github.com/abagayev/laravel-migration-shortcuts

Please or to participate in this conversation.