laravel/framework · error · LogicException

This database driver does not support dropping all views.

Error message

This database driver does not support dropping all views.

What it means

Base Builder::dropAllViews() throws LogicException because the connected driver's SchemaBuilder does not override it. Only drivers that expose view catalogues (e.g. Postgres, SQL Server, MySQL) implement it; SQLite and incomplete custom drivers do not. It is a declared capability gap.

Source

Thrown at src/Illuminate/Database/Schema/Builder.php:588

     * @return void
     *
     * @throws \LogicException
     */
    public function dropAllTables()
    {
        throw new LogicException('This database driver does not support dropping all tables.');
    }

    /**
     * Drop all views from the database.
     *
     * @return void
     *
     * @throws \LogicException
     */
    public function dropAllViews()
    {
        throw new LogicException('This database driver does not support dropping all views.');
    }

    /**
     * Drop all types from the database.
     *
     * @return void
     *
     * @throws \LogicException
     */
    public function dropAllTypes()
    {
        throw new LogicException('This database driver does not support dropping all types.');
    }

    /**
     * Rename a table on the schema.
     *
     * @param  string  $from

View on GitHub (pinned to bd6b5437e6)

Solutions

  1. Use a driver that implements dropAllViews (pgsql, mysql, sqlsrv).
  2. If using SQLite, drop individual views with DB::statement('DROP VIEW IF EXISTS name').
  3. Implement dropAllViews() on your custom Builder subclass.

Example fix

// before
Schema::dropAllViews();

// after (SQLite or unsupported driver)
foreach (DB::select("SELECT name FROM sqlite_master WHERE type='view'") as $v) {
    DB::statement('DROP VIEW IF EXISTS '.$v->name);
}
Defensive patterns

Strategy: type-guard

Validate before calling

$builder = Schema::getConnection()->getSchemaBuilder();
if ((new \ReflectionMethod($builder, 'dropAllViews'))->getDeclaringClass()->getName()
    === \Illuminate\Database\Schema\Builder::class) {
    // unsupported — skip or fall back
}

Type guard

function driverSupportsDropAllViews(): bool
{
    $builder = Schema::getConnection()->getSchemaBuilder();

    return (new \ReflectionMethod($builder, 'dropAllViews'))
        ->getDeclaringClass()->getName() !== \Illuminate\Database\Schema\Builder::class;
}

Try / catch

try {
    Schema::dropAllViews();
} catch (\LogicException $e) {
    // unsupported driver — skip silently or surface
}

Prevention

When it happens

Trigger: Calling Schema::dropAllViews() or a test/maintenance script that clears views, while connected through a driver whose builder lacks the override (notably SQLite or a third-party driver).

Common situations: Running migrate:fresh -- --views on SQLite; pointing a test suite at SQLite while the migration path tries to drop views; a custom driver missing the method.

Related errors


AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06). Data as JSON: /data/errors/c453b0ffca39bb12.json. Report an issue: GitHub.