{"record":{"id":"c9184386b980e21a","repo":"n8n-io/n8n","slug":"ondeletetype-relation-ondelete-is-not-support","errorCode":null,"errorMessage":"OnDeleteType \"${relation.onDelete}\" is not supported for ${driver.options.type}!","messagePattern":"OnDeleteType \"(.+?)\" is not supported for (.+?)!","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/typeorm/src/metadata-builder/EntityMetadataValidator.ts","lineNumber":160,"sourceCode":"\t\t\tif (relation.isManyToMany || relation.isOneToMany) {\n\t\t\t\t// we skip relations for which persistence is disabled since initialization in them cannot harm somehow\n\t\t\t\tif (relation.persistenceEnabled === false) return;\n\n\t\t\t\t// get entity relation value and check if its an array\n\t\t\t\tconst relationInitializedValue = relation.getEntityValue(entityInstance);\n\t\t\t\tif (Array.isArray(relationInitializedValue)) throw new InitializedRelationError(relation);\n\t\t\t}\n\t\t});\n\n\t\t// validate relations\n\t\tentityMetadata.relations.forEach((relation) => {\n\t\t\t// check OnDeleteTypes\n\t\t\tif (\n\t\t\t\tdriver.supportedOnDeleteTypes &&\n\t\t\t\trelation.onDelete &&\n\t\t\t\t!driver.supportedOnDeleteTypes.includes(relation.onDelete)\n\t\t\t) {\n\t\t\t\tthrow new TypeORMError(\n\t\t\t\t\t`OnDeleteType \"${relation.onDelete}\" is not supported for ${driver.options.type}!`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// check OnUpdateTypes\n\t\t\tif (\n\t\t\t\tdriver.supportedOnUpdateTypes &&\n\t\t\t\trelation.onUpdate &&\n\t\t\t\t!driver.supportedOnUpdateTypes.includes(relation.onUpdate)\n\t\t\t) {\n\t\t\t\tthrow new TypeORMError(\n\t\t\t\t\t`OnUpdateType \"${relation.onUpdate}\" is not valid for ${driver.options.type}!`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// check join tables:\n\t\t\t// using JoinTable is possible only on one side of the many-to-many relation\n\t\t\t// todo(dima): fix","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/metadata-builder/EntityMetadataValidator.ts#L142-L178","documentation":"Thrown by EntityMetadataValidator.validate during the relations loop when a relation declares an onDelete option whose value is not in driver.supportedOnDeleteTypes for the active database. The guard requires driver.supportedOnDeleteTypes to be set, relation.onDelete to be set, and includes() to be false to throw.","triggerScenarios":"Setting @ManyToOne(... { onDelete: 'SET NULL' }) on a driver that does not support that action, or using a non-standard string value (typo) such as 'RESTRICTED' instead of 'RESTRICT'.","commonSituations":"Switching databases (e.g. SQLite, which supports only a subset of referential actions); typos in onDelete strings; copying MySQL-only options onto a driver that does not implement them.","solutions":["Use a value listed in driver.supportedOnDeleteTypes for your database (typically 'RESTRICT' | 'SET NULL' | 'CASCADE' | 'NO ACTION' | 'DEFAULT').","If the driver (e.g. SQLite) does not support the action, drop onDelete or pick one it supports.","Centralize referential-action strings in a shared const enum to prevent typos."],"exampleFix":"// before\n@ManyToOne(() => User, (u) => u.posts, { onDelete: 'RESTRICTED' })\nauthor: User;\n\n// after\n@ManyToOne(() => User, (u) => u.posts, { onDelete: 'RESTRICT' })\nauthor: User;","handlingStrategy":"validation","validationCode":"function assertOnDeleteSupported(dataSource: DataSource): string[] {\n  const supported = dataSource.driver.supportedOnDeleteTypes\n    ? new Set(dataSource.driver.supportedOnDeleteTypes as string[])\n    : null;\n  if (!supported) return [];\n  const problems: string[] = [];\n  for (const meta of dataSource.entityMetadatas) {\n    for (const rel of meta.relations) {\n      if (rel.onDelete && !supported.has(rel.onDelete)) {\n        problems.push(`${meta.targetName}.${rel.propertyPath} onDelete='${rel.onDelete}' not supported by ${dataSource.options.type}`);\n      }\n    }\n  }\n  return problems;\n}","typeGuard":null,"tryCatchPattern":"try {\n  await dataSource.initialize();\n} catch (err) {\n  if (err.message.includes('OnDeleteType') && err.message.includes('is not supported for')) {\n    // pick a value from driver.supportedOnDeleteTypes\n  }\n  throw err;\n}","preventionTips":["Centralize referential-action strings in a shared const enum typed against driver.supportedOnDeleteTypes.","Run the post-init OnDelete validator in CI for every driver target.","When switching databases, audit onDelete options since supported sets differ (e.g. SQLite)."],"tags":["on-delete","foreign-key","driver","startup"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}