{"id":"9d478e50fc8f09ca","repo":"typeorm/typeorm","slug":"supplied-index-indexorname-was-not-found-in-tab-9d478e","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/spanner/SpannerQueryRunner.ts","lineNumber":1680,"sourceCode":"     * @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 =\n            tableOrName instanceof Table\n                ? tableOrName\n                : await this.getCachedTable(tableOrName)\n        const index =\n            indexOrName instanceof TableIndex\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\n        // new 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(table, 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","sourceCodeStart":1662,"sourceCodeEnd":1698,"githubUrl":"https://github.com/typeorm/typeorm/blob/04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96/src/driver/spanner/SpannerQueryRunner.ts#L1662-L1698","documentation":"Thrown by SpannerQueryRunner.dropIndex when the supplied index (by TableIndex object or by name string) is not present in the cached table's `indices` array. Suppressed when ifExists:true is passed, which is the idiomatic way to drop indexes that may not exist.","triggerScenarios":"Calling dropIndex(table, 'idx_user_email') where the index was never created, already dropped, or named differently. Common when migrations run partially or when an index name was changed by a naming-strategy update.","commonSituations":"Re-running a migration after a partial failure; deploying to an environment whose schema drifted; renaming indexes via NamingStrategy changes; concurrency where another process dropped the index first.","solutions":["Pass ifExists:true: `await qr.dropIndex('user', 'idx_user_email', true)`.","Check existence first via getTable and the indices array before dropping.","Confirm the actual index name from INFORMATION_SCHEMA.INDEXES on spanner (`INDEX_NAME`) and align your migration.","Use up/down idempotent migration patterns so partial replays don't leave stale drop steps."],"exampleFix":"// before\nawait queryRunner.dropIndex('user', 'idx_user_email')\n\n// after\nawait queryRunner.dropIndex('user', 'idx_user_email', true)\n// or\nconst t = await queryRunner.getTable('user')\nif (t?.indices.some(i => i.name === 'idx_user_email')) {\n  await queryRunner.dropIndex(t!, 'idx_user_email')\n}","handlingStrategy":"validation","validationCode":"async function safeDropIndex(qr: QueryRunner, tableName: string, name: string) {\n  await qr.dropIndex(tableName, name, true) // ifExists\n}","typeGuard":"function indexExists(table: Table, name: string): boolean {\n  return table.indices.some(i => i.name === name)\n}","tryCatchPattern":"try {\n  await qr.dropIndex('user', 'idx_email')\n} catch (e) {\n  if (e instanceof TypeORMError && /was not found in table/.test(e.message)) return\n  throw e\n}","preventionTips":["Always pass ifExists:true for dropIndex calls in idempotent migrations.","Look up the index name from INFORMATION_SCHEMA before dropping.","Keep index names stable via explicit naming to avoid drift."],"tags":["spanner","schema","index","not-found","migration"],"analyzedSha":"04ff4daedcf60fa4ffd0d5d33bbafaac1a9bbc96","analyzedAt":"2026-08-03T18:27:32.281Z","schemaVersion":2}