n8n-io/n8n · error · TypeORMError

Index ${indexName}contains column that is missing in the ent

Error message

Index ${indexName}contains column that is missing in the entity (${entityName}): ${propertyPath}

What it means

Thrown by IndexMetadata.build when an @Index references a property path that is neither a column, a relation with a join column, nor otherwise resolvable on the entity. The builder first tries findColumnWithPropertyPath, then looks for a @ManyToOne/@OneToOne relation with isWithJoinColumn and matching propertyName; only if both fail does it throw, naming the index (if givenName was set) and the entity targetName.

Source

Thrown at packages/@n8n/typeorm/src/metadata/IndexMetadata.ts:216

			}

			this.columns = columnPropertyPaths
				.map((propertyPath) => {
					const columnWithSameName = this.entityMetadata.columns.find(
						(column) => column.propertyPath === propertyPath,
					);
					if (columnWithSameName) {
						return [columnWithSameName];
					}
					const relationWithSameName = this.entityMetadata.relations.find(
						(relation) => relation.isWithJoinColumn && relation.propertyName === propertyPath,
					);
					if (relationWithSameName) {
						return relationWithSameName.joinColumns;
					}
					const indexName = this.givenName ? '"' + this.givenName + '" ' : '';
					const entityName = this.entityMetadata.targetName;
					throw new TypeORMError(
						`Index ${indexName}contains column that is missing in the entity (${entityName}): ` +
							propertyPath,
					);
				})
				.reduce((a, b) => a.concat(b));
		}

		this.columnNamesWithOrderingMap = Object.keys(map).reduce(
			(updatedMap, key) => {
				const column = this.entityMetadata.columns.find((column) => column.propertyPath === key);
				if (column) updatedMap[column.databasePath] = map[key];

				return updatedMap;
			},
			{} as { [key: string]: number },
		);

		this.name = this.givenName

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Inspect every entry in the @Index columns array against the entity's @Column and join-column relations.
  2. Rebuild the entity metadata (drop dist, restart) after renaming columns so stale decorators are not loaded.
  3. If the column was intentionally removed, remove it from the index definition as well.

Example fix

// before
@Entity()
@Index('idx_email', ['emial']) // typo
export class User { @Column() email: string; }

// after
@Entity()
@Index('idx_email', ['email'])
export class User { @Column() email: string; }
Defensive patterns

Strategy: validation

Validate before calling

// After DataSource.initialize(), verify every declared index resolves
function validateIndices(dataSource: DataSource): string[] {
  const problems: string[] = [];
  for (const meta of dataSource.entityMetadatas) {
    const cols = new Set(meta.columns.map((c) => c.propertyPath));
    const joinCols = new Set(
      meta.relations.filter((r) => r.isWithJoinColumn).map((r) => r.propertyName),
    );
    for (const idx of meta.indices) {
      for (const givenPath of (idx.givenColumnNames as string[] | undefined) ?? []) {
        if (!cols.has(givenPath) && !joinCols.has(givenPath)) {
          problems.push(`${meta.targetName}.@Index('${idx.givenName}') -> missing ${givenPath}`);
        }
      }
    }
  }
  return problems;
}

Try / catch

try {
  await dataSource.initialize();
} catch (err) {
  if (err.message.includes('Index ') && err.message.includes('contains column that is missing')) {
    // surface the offending index/entity pair to the operator
  }
  throw err;
}

Prevention

When it happens

Trigger: Declaring @Index('my_idx', ['foo']) where 'foo' is not a column on the same entity; renaming a column without updating index column lists; pointing an index at a property that lives only on a parent class without proper STI mapping.

Common situations: Typos in index column arrays, copy-pasted indices between entities, removing a column that an index still references, or referencing a getter-only / virtual property that has no backing column.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/0f6c697eec698904. Report an issue: GitHub.