{"record":{"id":"2d277fc587f8f8c1","repo":"n8n-io/n8n","slug":"column-oldtablecolumnorname-was-not-found-in","errorCode":null,"errorMessage":"Column \"${oldTableColumnOrName}\" was not found in the \"${table.name}\" table.","messagePattern":"Column \"(.+?)\" was not found in the \"(.+?)\" table\\.","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/typeorm/src/driver/sqlite-abstract/AbstractSqliteQueryRunner.ts","lineNumber":528,"sourceCode":"\t\tawait this.recreateTable(changedTable, table);\n\t}\n\n\t/**\n\t * Renames column in the given table.\n\t */\n\tasync renameColumn(\n\t\ttableOrName: Table | string,\n\t\toldTableColumnOrName: TableColumn | string,\n\t\tnewTableColumnOrName: TableColumn | string,\n\t): Promise<void> {\n\t\tconst table = InstanceChecker.isTable(tableOrName)\n\t\t\t? tableOrName\n\t\t\t: await this.getCachedTable(tableOrName);\n\t\tconst oldColumn = InstanceChecker.isTableColumn(oldTableColumnOrName)\n\t\t\t? oldTableColumnOrName\n\t\t\t: table.columns.find((c) => c.name === oldTableColumnOrName);\n\t\tif (!oldColumn)\n\t\t\tthrow new TypeORMError(\n\t\t\t\t`Column \"${oldTableColumnOrName}\" was not found in the \"${table.name}\" table.`,\n\t\t\t);\n\n\t\tlet newColumn: TableColumn | undefined = undefined;\n\t\tif (InstanceChecker.isTableColumn(newTableColumnOrName)) {\n\t\t\tnewColumn = newTableColumnOrName;\n\t\t} else {\n\t\t\tnewColumn = oldColumn.clone();\n\t\t\tnewColumn.name = newTableColumnOrName;\n\t\t}\n\n\t\treturn this.changeColumn(table, oldColumn, newColumn);\n\t}\n\n\t/**\n\t * Changes a column in the table.\n\t */\n\tasync changeColumn(","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/driver/sqlite-abstract/AbstractSqliteQueryRunner.ts#L510-L546","documentation":"renameColumn() resolves the old column by name against the table's cached metadata; if no column matches it throws TypeORMError. This is a precondition failure — the column you are renaming does not exist in the table definition TypeORM has loaded.","triggerScenarios":"Calling renameColumn(table, 'oldName', 'newName') where 'oldName' is not a column, or passing a stale Table object whose columns do not reflect the live database.","commonSituations":"Migration ordering (renaming a column before the migration that adds it), a typo in the column name, running migrations out of order, or the cached table metadata being stale.","solutions":["Verify the exact current column name in the DB/schema before renaming.","Ensure migrations run in strict order — the column must exist first.","Re-fetch the table via getCachedTable() if metadata may be stale.","Double-check spelling and case (SQLite identifiers are case-insensitive but typos still miss)."],"exampleFix":"// before\nawait queryRunner.renameColumn('user', 'firstName', 'givenName');\n\n// after\nconst table = await queryRunner.getTable('user');\nif (table?.findColumnByName('firstName')) {\n  await queryRunner.renameColumn('user', 'firstName', 'givenName');\n}","handlingStrategy":"validation","validationCode":"const table = await queryRunner.getTable('user');\nif (!table?.findColumnByName('firstName')) {\n  throw new Error('Cannot rename: column firstName does not exist');\n}\nawait queryRunner.renameColumn(table!, 'firstName', 'givenName');","typeGuard":"const columnExists = async (qr: QueryRunner, tableName: string, col: string): Promise<boolean> =>\n  Boolean((await qr.getTable(tableName))?.findColumnByName(col));","tryCatchPattern":null,"preventionTips":["Verify the current column name against the live schema before renaming.","Keep migrations strictly ordered.","Re-fetch table metadata when it may be stale."],"tags":["database","migration","sqlite"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}