Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect behaviour "SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification." #50303

Closed
Cryborg opened this issue Feb 28, 2024 · 3 comments

Comments

@Cryborg
Copy link

Cryborg commented Feb 28, 2024

Laravel Version

10.46

PHP Version

8.2

Database Driver & Version

SQLite

Description

In a migration, I have the following code that worked well a few days ago :

    public function down(): void
    {
        Schema::table('answers', function(Blueprint $table) {
            $table->dropColumn('corrected_text');
            $table->dropColumn('options');
            $table->dropColumn('score');
        });
    }

Now, I have this message when I run the tests : "SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification."

The solution I found is this :

    public function down(): void
    {
        Schema::table('answers', function (Blueprint $table) {
            $table->dropColumn('corrected_text');
        });
        Schema::table('answers', function (Blueprint $table) {
            $table->dropColumn('options');
        });
        Schema::table('answers', function (Blueprint $table) {
            $table->dropColumn('score');
        });
    }

But it seems hacky and looks like a regression to me. I updated to 10.46 and I was on 10.40 before.

Steps To Reproduce

Use multiple dropColumns in a migration file, and run unit tests using SQLite DB.

@hafezdivandari
Copy link
Contributor

hafezdivandari commented Feb 28, 2024

This happens when you have doctrine/dbal package installed.

To fix this, you may call Schema::useNativeSchemaOperationsIfPossible() method within the boot method of your App\Providers\AppServiceProvider class. check #45258

PS: This won't happen on Laravel 11.x

@Cryborg
Copy link
Author

Cryborg commented Feb 28, 2024

Schema::useNativeSchemaOperationsIfPossible()

It solved the problem, thanks!

Just for my knowledge, why do I have to do this now? doctrine/dbal has been installed for months on my project.

@hafezdivandari
Copy link
Contributor

Nothing changed recently on this manner (dropping columns on 10.x), maybe you didn't run your migrations after installing doctrine/dbal?

@laravel laravel locked and limited conversation to collaborators Feb 29, 2024
@crynobone crynobone converted this issue into discussion #50308 Feb 29, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants