{"id":"a636403697d517cb","repo":"typeorm/typeorm","slug":"supplied-index-indexorname-was-not-found-in-tab-a63640","errorCode":null,"errorMessage":"Supplied index ${indexOrName} was not found in table ${table.name}","messagePattern":"Supplied index (.+?) was not found in table (.+?)","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"src/driver/oracle/OracleQueryRunner.ts","lineNumber":2358,"sourceCode":"     *\n     * @param tableOrName\n     * @param indexOrName\n     * @param ifExists\n     */\n    async dropIndex(\n        tableOrName: Table | string,\n        indexOrName: TableIndex | string,\n        ifExists?: boolean,\n    ): Promise<void> {\n        const table = InstanceChecker.isTable(tableOrName)\n            ? tableOrName\n            : await this.getCachedTable(tableOrName)\n        const index = InstanceChecker.isTableIndex(indexOrName)\n            ? indexOrName\n            : table.indices.find((i) => i.name === indexOrName)\n        if (!index) {\n            if (ifExists) return\n            throw new TypeORMError(\n                `Supplied index ${indexOrName} was not found in table ${table.name}`,\n            )\n        }\n        // old index may be passed without name. In this case we generate index name manually.\n        index.name ??= this.generateIndexName(table, index)\n\n        const up = this.dropIndexSql(index)\n        const down = this.createIndexSql(table, index)\n        await this.executeQueries(up, down)\n        table.removeIndex(index)\n    }\n\n    /**\n     * Drops an indices from the table.\n     *\n     * @param tableOrName\n     * @param indices\n     * @param ifExists","sourceCodeStart":2340,"sourceCodeEnd":2376,"githubUrl":"https://github.com/typeorm/typeorm/blob/04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96/src/driver/oracle/OracleQueryRunner.ts#L2340-L2376","documentation":"Thrown by OracleQueryRunner.dropIndex when the supplied index name or TableIndex object cannot be matched in table.indices. The runner searches table.indices by .name; if nothing matches and ifExists is not true, it throws. This is purely a metadata-lookup failure against the driver's cached schema view.","triggerScenarios":"Calling queryRunner.dropIndex(table, \"idx_name\") where 'idx_name' is not present in table.indices[].name. Happens with typoed index names, dropping an index already removed, or naming-strategy-generated names that differ from the explicit string supplied.","commonSituations":"Generated index names that differ from hand-written migration strings; index already dropped by a prior sync; case sensitivity on Oracle identifiers; dropping indexes created outside TypeORM.","solutions":["Pass ifExists: true as the third argument to tolerate a missing index.","Verify the index name in ALL_INDICES/USER_INDICES or table.indices before dropping.","Pass a TableIndex object whose .name matches the cached metadata rather than a bare string.","Refresh cached metadata with getCachedTable if the schema was changed externally."],"exampleFix":"// before\nawait queryRunner.dropIndex(\"users\", \"idx_users_email\");\n\n// after\nawait queryRunner.dropIndex(\"users\", \"idx_users_email\", true);","handlingStrategy":"validation","validationCode":"const table = await queryRunner.getTable(\"users\");\nconst idxName = \"idx_users_email\";\nif ((table?.indices ?? []).some(i => i.name === idxName)) {\n  await queryRunner.dropIndex(\"users\", idxName);\n}","typeGuard":"import { TableIndex } from \"typeorm\";\nfunction isTableIndex(o: unknown): o is TableIndex {\n  return typeof o === \"object\" && o !== null && \"name\" in o && Array.isArray((o as any).columnNames);\n}","tryCatchPattern":null,"preventionTips":["Pass ifExists:true for index drops that may already have run.","Read index names from table.indices rather than hard-coding.","Watch for Oracle identifier case sensitivity when matching names."],"tags":["oracle","index","schema","migration"],"analyzedSha":"04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96","analyzedAt":"2026-08-03T18:27:32.281Z","schemaVersion":2}