{"record":{"id":"03221fe90990a04d","repo":"clockworklabs/SpacetimeDB","slug":"removeindex-index-name-not-found-in-old-modul","errorCode":null,"errorMessage":"RemoveIndex: `{index_name}` not found in old module def","messagePattern":"RemoveIndex: `(.+?)` not found in old module def","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/engine/src/update.rs","lineNumber":353,"sourceCode":"                    .filter_map(|(_, c)| c.data.unique_columns())\n                    .any(|unique_cols| unique_cols == &index_cols);\n\n                log!(logger, \"Creating index `{index_name}` on table `{table_full_name}`\");\n\n                let mut index_schema = IndexSchema::from_module_def(owning_def, index_def, table_id, 0.into());\n\n                // Apply namespace prefix for submodule indexes\n                index_schema.index_name = namespace.join_raw(&index_schema.index_name);\n                index_schema.alias = index_schema.alias.as_ref().map(|alias| namespace.join_raw(alias));\n\n                stdb.create_index(tx, index_schema, is_unique)?;\n            }\n            spacetimedb_schema::auto_migrate::AutoMigrateStep::RemoveIndex(key) => {\n                let (namespace, index_name) = key;\n                let (_owning_def, table_def) = plan\n                    .old\n                    .find_storing_table(namespace, index_name)\n                    .ok_or_else(|| anyhow::anyhow!(\"RemoveIndex: `{index_name}` not found in old module def\"))?;\n                let table_full_name = joined(namespace, &table_def.name);\n                let stored_name = namespace.join_raw(&index_name.clone().into());\n                let table_id = stdb.table_id_from_name_mut(tx, &table_full_name)?.unwrap();\n                let table_schema = stdb.schema_for_table_mut(tx, table_id)?;\n\n                let index_schema = table_schema\n                    .indexes\n                    .iter()\n                    .find(|index| index.index_name == stored_name)\n                    .ok_or_else(|| anyhow::anyhow!(\"Index `{index_name}` not found in table `{table_full_name}`\"))?;\n\n                log!(logger, \"Dropping index `{index_name}` on table `{table_full_name}`\");\n                stdb.drop_index(tx, index_schema.index_id)?;\n            }\n            spacetimedb_schema::auto_migrate::AutoMigrateStep::ChangeTableAccessorName(table_name_key) => {\n                let (namespace, local) = table_name_key;\n                let table_name = joined(namespace, local);\n                let (_, new_table_def): (&ModuleDef, &spacetimedb_schema::def::TableDef) =","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/engine/src/update.rs#L335-L371","documentation":"Auto-migrate step RemoveIndex: find_storing_table over plan.old failed — the old module def has no table that stores the index the plan wants to drop. The removal step references an index whose owning table is missing from the old def, an internal plan/old-def inconsistency.","triggerScenarios":"RemoveIndex steps computed against an older def revision where the table existed; the storing table was renamed/removed while the index step survived; hand-built plans with dangling keys.","commonSituations":"Cached migration plans reused across module edits; upstream differ bugs; submodule reorganization between def versions.","solutions":["Regenerate the plan from the old def that matches the currently published module","Verify the (namespace, index name) key resolves in plan.old before applying","Report upstream if the differ emitted the stale step"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match auto_migrate_database(&stdb, &mut tx, auth, &plan, &logger) {\n    Err(e) if e.to_string().contains(\"RemoveIndex:\") && e.to_string().contains(\"not found in old module def\") => {\n        anyhow::bail!(\"plan/old-def desync: {e:#}; rebuild the plan from the currently published module\");\n    }\n    r => r,\n}","preventionTips":["Rebuild removal steps against the old def that matches the published module","Do not cache plans across module versions","Track def revisions alongside cached plans if caching is unavoidable"],"tags":["rust","spacetimedb","migration","index","internal-invariant"],"backgroundTag":"migration-plan-invalid","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}