Brainmaniac's avatar

SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification.

Hello,

I upgraded from laravel 8 to 9 and now my (single) pest test fails with the following error:

 SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification.

It fails here:

 at vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:156
    152▕     protected function ensureCommandsAreValid(Connection $connection)
    153▕     {
    154▕         if ($connection instanceof SQLiteConnection) {
    155▕             if ($this->commandsNamed(['dropColumn', 'renameColumn'])->count() > 1) {
  ➜ 156▕                 throw new BadMethodCallException(
    157▕                     "SQLite doesn't support multiple calls to dropColumn / renameColumn in a single modification."
    158▕                 );
    159▕             }
    160▕ 

My test code:

<?php

use App\Models\StaticPage;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
uses(\Tests\TestCase::class)->in('Feature');

it('has howTo page', function () {
    // Prepare
    $post = StaticPage::factory()->create();

    // Act
    $response = $this->get(route('howTo'));

    // Assert
    $response->assertOk();

});

I have no idea what happened. I tried to look in to if I need to upgrade sqlite (now running 3.37) but i don't think that it is. Any ideas?

1 like
3 replies
Brainmaniac's avatar

Ok, I fount it. It has to do with some of my migrations apparently... strange tho. I have no migration that removes and renames anything... It is all from a dropColumn migration

Brainmaniac's avatar
Brainmaniac
OP
Best Answer
Level 2

Ok, got it!

So, I had a migration looking like this:

public function up()
    {
        Schema::table('furniture_infos', function (Blueprint $table) {
            $table->dropColumn('c1');
            $table->dropColumn('c2');
            $table->dropColumn('c3');
        });
    }

It should have looked like this:

$table->dropColumn(['c1', 'c2', 'c3']);
9 likes

Please or to participate in this conversation.