{"record":{"id":"226900fc523b04cd","repo":"n8n-io/n8n","slug":"supplied-check-constraint-was-not-found-in-table","errorCode":null,"errorMessage":"Supplied check constraint was not found in table ${table.name}","messagePattern":"Supplied check constraint was not found in table (.+?)","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/typeorm/src/driver/sqlite-abstract/AbstractSqliteQueryRunner.ts","lineNumber":857,"sourceCode":"\t\tcheckConstraints.forEach((checkConstraint) => changedTable.addCheckConstraint(checkConstraint));\n\t\tawait this.recreateTable(changedTable, table);\n\t}\n\n\t/**\n\t * Drops check constraint.\n\t */\n\tasync dropCheckConstraint(\n\t\ttableOrName: Table | string,\n\t\tcheckOrName: TableCheck | 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 checkConstraint = InstanceChecker.isTableCheck(checkOrName)\n\t\t\t? checkOrName\n\t\t\t: table.checks.find((c) => c.name === checkOrName);\n\t\tif (!checkConstraint)\n\t\t\tthrow new TypeORMError(`Supplied check constraint was not found in table ${table.name}`);\n\n\t\tawait this.dropCheckConstraints(table, [checkConstraint]);\n\t}\n\n\t/**\n\t * Drops check constraints.\n\t */\n\tasync dropCheckConstraints(\n\t\ttableOrName: Table | string,\n\t\tcheckConstraints: TableCheck[],\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\n\t\t// clone original table and remove check constraints from cloned table\n\t\tconst changedTable = table.clone();\n\t\tcheckConstraints.forEach((checkConstraint) =>","sourceCodeStart":839,"sourceCodeEnd":875,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/driver/sqlite-abstract/AbstractSqliteQueryRunner.ts#L839-L875","documentation":"dropCheckConstraint() resolves the check constraint by name (or object) against the cached table; if none matches it throws TypeORMError. The check constraint you are trying to drop does not exist in the table definition TypeORM has loaded.","triggerScenarios":"Calling dropCheckConstraint(table, 'constraintName') where 'constraintName' is not present in table.checks of the cached table.","commonSituations":"Re-running a migration that already dropped it, a typo in the constraint name (SQLite often auto-generates these), or stale cached metadata.","solutions":["Resolve the actual check-constraint name from the live schema via getTable().checks before dropping.","Make the drop idempotent — check existence first.","Re-fetch the table via getTable() if metadata may be stale."],"exampleFix":"// before\nawait queryRunner.dropCheckConstraint('user', 'CHK_user_age');\n\n// after\nconst table = await queryRunner.getTable('user');\nif (table?.checks.some((c) => c.name === 'CHK_user_age')) {\n  await queryRunner.dropCheckConstraint(table!, 'CHK_user_age');\n}","handlingStrategy":"validation","validationCode":"const table = await queryRunner.getTable('user');\nif (table?.checks.some((c) => c.name === 'CHK_user_age')) {\n  await queryRunner.dropCheckConstraint(table!, 'CHK_user_age');\n}","typeGuard":"const checkExists = async (qr: QueryRunner, tableName: string, name: string): Promise<boolean> =>\n  Boolean((await qr.getTable(tableName))?.checks.some((c) => c.name === name));","tryCatchPattern":null,"preventionTips":["Resolve the real check-constraint name from the live schema.","Make constraint drops idempotent.","Re-fetch table metadata when stale."],"tags":["database","migration","sqlite","constraints"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}