laravel/framework · error · InvalidArgumentException

There is no column with name '$column' on table '$table'.

Error message

There is no column with name '$column' on table '$table'.

What it means

Thrown by Schema\Builder::getColumnType() after it iterates every column returned by getColumns() and finds no case-insensitive match for the requested name. It is an InvalidArgumentException, meaning the call itself is invalid for the current table state - the column genuinely is not visible to the driver's introspection query. The comparison uses strtolower on both sides, so case is never the culprit; the column is absent, misnamed, or not yet migrated.

Solutions

  1. Run the outstanding migration on this connection (php artisan migrate) and confirm the column exists with Schema::getColumnListing($table).
  2. Verify the exact column name against the database (SHOW COLUMNS, \d table, sp_columns) - getColumnType matches case-insensitively, so a mismatch means the column truly is missing.
  3. Pass the un-prefixed table name; getColumns() prepends connection->getTablePrefix() itself.
  4. If using a schema-qualified reference like 'public.users', confirm parseSchemaAndTable resolves it to the schema the driver introspects.
  5. Guard with Schema::hasColumn($table, $column) before invoking getColumnType.

Example fix

// before
$type = Schema::getColumnType('users', 'email_address');

// after
if (Schema::hasColumn('users', 'email_address')) {
    $type = Schema::getColumnType('users', 'email_address');
} else {
    $type = Schema::getColumnType('users', 'email'); // correct name
}
Defensive patterns

Strategy: validation

Validate before calling

use Illuminate\Support\Facades\Schema;

if (Schema::hasColumn($table, $column)) {
    $type = Schema::getColumnType($table, $column);
} else {
    throw new \DomainException("Column {$column} not found on {$table}; available: " . implode(',', Schema::getColumnListing($table)));
}

Type guard

function columnExists(string $table, string $column): bool
{
    return in_array(
        strtolower($column),
        array_map('strtolower', Schema::getColumnListing($table)),
        true
    );
}

Try / catch

try {
    $type = Schema::getColumnType($table, $column);
} catch (\InvalidArgumentException $e) {
    Log::warning('Column type lookup failed', ['table' => $table, 'column' => $column]);
    throw $e;
}

Prevention

When it happens

Trigger: Calling Schema::getColumnType($table, $column) (or any internal caller such as renameColumn/change detection) with a column name that does not exist in information_schema for that table. Also fires when $table is schema-qualified or carries a prefix that double-resolves, so the introspection query targets the wrong physical table.

Common situations: Migration that adds the column has not been run on the current connection; typo in the column name; quoting the wrong table or supplying a prefix the connection already applies; pointing at a read-replica whose DDL has not propagated; the column is a view column or alias, not a real information_schema column.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/f7c27e58c0558b78. Report an issue: GitHub.

Appendix: source

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

     *
     * @param  string  $table
     * @param  string  $column
     * @param  bool  $fullDefinition
     * @return string
     *
     * @throws \InvalidArgumentException
     */
    public function getColumnType($table, $column, $fullDefinition = false)
    {
        $columns = $this->getColumns($table);

        foreach ($columns as $value) {
            if (strtolower($value['name']) === strtolower($column)) {
                return $fullDefinition ? $value['type'] : $value['type_name'];
            }
        }

        throw new InvalidArgumentException("There is no column with name '$column' on table '$table'.");
    }

    /**
     * Get the column listing for a given table.
     *
     * @param  string  $table
     * @return list<string>
     */
    public function getColumnListing($table)
    {
        return array_column($this->getColumns($table), 'name');
    }

    /**
     * Get the columns for a given table.
     *
     * @param  string  $table
     * @return list<array{name: string, type: string, type_name: string, collation: string|null, nullable: bool, default: mixed, auto_increment: bool, comment: string|null, generation: array{type: string, expression: string|null}|null}>

View on GitHub (pinned to e0f6eb3518)