{"record":{"id":"9dc945fa73a483cd","repo":"n8n-io/n8n","slug":"column-column-was-not-found-in-table-table","errorCode":null,"errorMessage":"Column \"${column}\" was not found in table \"${table.name}\"","messagePattern":"Column \"(.+?)\" was not found in table \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/typeorm/src/driver/sqlite-abstract/AbstractSqliteQueryRunner.ts","lineNumber":684,"sourceCode":"\t\tawait this.dropColumns(table, [column]);\n\t}\n\n\t/**\n\t * Drops the columns in the table.\n\t */\n\tasync dropColumns(tableOrName: Table | string, columns: TableColumn[] | string[]): Promise<void> {\n\t\tconst table = InstanceChecker.isTable(tableOrName)\n\t\t\t? tableOrName\n\t\t\t: await this.getCachedTable(tableOrName);\n\n\t\t// clone original table and remove column and its constraints from cloned table\n\t\tconst changedTable = table.clone();\n\t\tcolumns.forEach((column: TableColumn | string) => {\n\t\t\tconst columnInstance = InstanceChecker.isTableColumn(column)\n\t\t\t\t? column\n\t\t\t\t: table.findColumnByName(column);\n\t\t\tif (!columnInstance)\n\t\t\t\tthrow new Error(`Column \"${column}\" was not found in table \"${table.name}\"`);\n\n\t\t\tchangedTable.removeColumn(columnInstance);\n\t\t\tchangedTable\n\t\t\t\t.findColumnUniques(columnInstance)\n\t\t\t\t.forEach((unique) => changedTable.removeUniqueConstraint(unique));\n\t\t\tchangedTable\n\t\t\t\t.findColumnIndices(columnInstance)\n\t\t\t\t.forEach((index) => changedTable.removeIndex(index));\n\t\t\tchangedTable\n\t\t\t\t.findColumnForeignKeys(columnInstance)\n\t\t\t\t.forEach((fk) => changedTable.removeForeignKey(fk));\n\t\t});\n\n\t\tawait this.recreateTable(changedTable, table);\n\t}\n\n\t/**\n\t * Creates a new primary key.","sourceCodeStart":666,"sourceCodeEnd":702,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/driver/sqlite-abstract/AbstractSqliteQueryRunner.ts#L666-L702","documentation":"Inside dropColumns(), each entry is resolved by name against the cached table; if any one is missing it throws (note: a plain `Error`, not TypeORMError). One of the columns in the batch you asked to drop does not exist in the cached table definition.","triggerScenarios":"Calling dropColumns(table, ['a','b','c']) where one of the names is not a column in the cached table.","commonSituations":"Re-running a drop migration, a typo in one of several names, a prior migration already removed one column, or stale cached metadata.","solutions":["Filter the list to only columns that currently exist before calling dropColumns.","Verify each column name against the live schema.","Re-fetch the table via getTable() if metadata may be stale."],"exampleFix":"// before\nawait queryRunner.dropColumns('user', ['a', 'b', 'c']);\n\n// after\nconst table = await queryRunner.getTable('user');\nconst toDrop = ['a', 'b', 'c'].filter((n) => table?.findColumnByName(n));\nif (toDrop.length) await queryRunner.dropColumns(table!, toDrop as any);","handlingStrategy":"validation","validationCode":"const table = await queryRunner.getTable('user');\nconst toDrop = ['a', 'b', 'c'].filter((n) => table?.findColumnByName(n));\nif (toDrop.length) {\n  await queryRunner.dropColumns(table!, toDrop as any);\n}","typeGuard":"const filterExistingColumns = async (\n  qr: QueryRunner,\n  tableName: string,\n  names: string[],\n): Promise<string[]> => {\n  const table = await qr.getTable(tableName);\n  return names.filter((n) => table?.findColumnByName(n));\n};","tryCatchPattern":null,"preventionTips":["Filter the batch to existing columns before calling dropColumns.","Re-fetch table metadata when stale.","Make batch drops idempotent."],"tags":["database","migration","sqlite"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}