Resolving Issues with PHPUnit, SQLite, and dropColumn

Laravel Database

If you're executing a Laravel migration that involves both dropping and adding columns, this can lead to complications when using SQLite, particularly when coupled with PHPUnit.


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

return new class extends Migration
    public function up(): void
        Schema::table('my_table_name', function (Blueprint $table)


In this context, it's important to note that SQLite won't create the new columns as it doesn't support this functionality. Conversely, there are no issues with this code when using MySQL.

To overcome this challenge, a simple approach is recommended: Split the dropping and adding of columns into two separate migrations. This solution ensures compatibility with both SQLite and MySQL.