{"id":"f7c27e58c0558b78","repo":"laravel/framework","slug":"there-is-no-column-with-name-column-on-table","errorCode":null,"errorMessage":"There is no column with name '$column' on table '$table'.","messagePattern":"There is no column with name '\\$column' on table '\\$table'\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Illuminate/Database/Schema/Builder.php","lineNumber":373,"sourceCode":"     *\n     * @param  string  $table\n     * @param  string  $column\n     * @param  bool  $fullDefinition\n     * @return string\n     *\n     * @throws \\InvalidArgumentException\n     */\n    public function getColumnType($table, $column, $fullDefinition = false)\n    {\n        $columns = $this->getColumns($table);\n\n        foreach ($columns as $value) {\n            if (strtolower($value['name']) === strtolower($column)) {\n                return $fullDefinition ? $value['type'] : $value['type_name'];\n            }\n        }\n\n        throw new InvalidArgumentException(\"There is no column with name '$column' on table '$table'.\");\n    }\n\n    /**\n     * Get the column listing for a given table.\n     *\n     * @param  string  $table\n     * @return list<string>\n     */\n    public function getColumnListing($table)\n    {\n        return array_column($this->getColumns($table), 'name');\n    }\n\n    /**\n     * Get the columns for a given table.\n     *\n     * @param  string  $table\n     * @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}>","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/laravel/framework/blob/bd6b5437e6ad87bb49f9b426724f07a9f64e9683/src/Illuminate/Database/Schema/Builder.php#L355-L391","documentation":"Thrown by Builder::getColumnType() when it iterates the table's columns (via getColumns()) and finds no row whose name matches the requested $column (case-insensitive). It is an InvalidArgumentException because the caller asked for the type of a column the schema manager cannot see. This usually means the column does not exist, was renamed/dropped in a migration that has not run, or the table prefix/schema is wrong.","triggerScenarios":"Calling Schema::getColumnType($table, $column) or any API that delegates to it (e.g. Doctrine-style type detection, $table->change() in a migration that reads the existing type) where $column is not present among the rows returned by compileColumns/processColumns for that table. Also triggered by passing a fully-qualified name with the wrong schema/prefix so getColumns() resolves a different table.","commonSituations":"Migration not yet run on the current environment (column exists in code but not in DB); column was renamed but old name still referenced; table prefix mismatch between config and actual table; typos in column name in a $table->change() migration; SQLite/old MySQL where the information_schema query returns unexpected casing.","solutions":["Verify the column actually exists: run Schema::getColumnListing($table) and check the name is present (case-insensitive).","Run php artisan migrate on the environment to apply pending migrations that create/rename the column.","Confirm config('database.connections.*.prefix') matches the table prefix actually used; Builder prepends getTablePrefix() at Builder.php:397.","If using a schema-qualified table name, pass only 'schema.table' (two parts); three parts throws error 225.","Check for casing drift: comparison is strtolower-based (Builder.php:368) so exact case is not required, but trailing spaces or hidden characters will fail."],"exampleFix":"// before\n$type = Schema::getColumnType('users', 'email_address');\n\n// after\n$columns = array_map('strtolower', Schema::getColumnListing('users'));\nif (in_array(strtolower('email_address'), $columns, true)) {\n    $type = Schema::getColumnType('users', 'email_address');\n} else {\n    // column missing — run migrations or fix the name\n}","handlingStrategy":"validation","validationCode":"$columns = array_map('strtolower', Schema::getColumnListing($table));\nif (! in_array(strtolower($column), $columns, true)) {\n    throw new \\InvalidArgumentException(\"Missing column {$column} on {$table}\");\n}\n$type = Schema::getColumnType($table, $column);","typeGuard":"function columnExists(string $table, string $column): bool\n{\n    $listing = array_map('strtolower', (array) Schema::getColumnListing($table));\n\n    return in_array(strtolower($column), $listing, true);\n}","tryCatchPattern":"try {\n    $type = Schema::getColumnType($table, $column);\n} catch (\\InvalidArgumentException $e) {\n    // log and degrade — column is absent, do not assume a type\n    $type = null;\n}","preventionTips":["Run php artisan migrate before introspecting schema in scripts.","Validate column names against getColumnListing() before calling getColumnType().","Verify the table prefix in config('database.connections.*.prefix').","Use two-part 'schema.table' references only."],"tags":["schema","database","migration","column-lookup"],"analyzedSha":"bd6b5437e6ad87bb49f9b426724f07a9f64e9683","analyzedAt":"2026-08-06T00:28:32.783Z","schemaVersion":2}