Skip to content

Conversation

amirhshokri
Copy link
Contributor

This PR adds support for detecting migrations that drop tables in the TableGuesser class.

Currently, TableGuesser can detect create and change patterns, but not drop migrations.

With this change, migrations like:

php artisan make:migration drop_users_table
php artisan make:migration drop_users

will now be correctly guessed.

@amirhshokri
Copy link
Contributor Author

amirhshokri commented Aug 10, 2025

@taylorotwell

Test failure is coming from Illuminate\Tests\Queue\FailOnExceptionMiddlewareTest::testMiddlewareDataProvider() method and unrelated.

@taylorotwell taylorotwell merged commit ab9e249 into laravel:12.x Aug 10, 2025
33 of 60 checks passed
@amirhshokri amirhshokri deleted the 12.x-improve-migration-table-name-guesser branch August 11, 2025 07:47
@amirhshokri amirhshokri changed the title [12.x] Add drop patterns support to TableGuesser for drop migrations [12.x] Add support for drop patterns to the make:migration command's TableGuesser. Aug 11, 2025
@AhmedAlaa4611
Copy link
Contributor

AhmedAlaa4611 commented Aug 25, 2025

Hello, @amirhshokri

The generated migration file using the php artisan make:migration drop_posts_table Artisan command looks like this:

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('posts', function (Blueprint $table) {
            //
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('posts', function (Blueprint $table) {
            //
        });
    }
};

Which is not indicate to drop anything. What do you think?

amirhshokri added a commit to amirhshokri/laravel-framework that referenced this pull request Aug 25, 2025
amirhshokri added a commit to amirhshokri/laravel-framework that referenced this pull request Aug 25, 2025
@amirhshokri
Copy link
Contributor Author

You’re right @AhmedAlaa4611
Thanks for pointing that out. I’ll revert this commit.

taylorotwell pushed a commit that referenced this pull request Aug 25, 2025
amirhshokri added a commit to amirhshokri/laravel-framework that referenced this pull request Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants