{"record":{"id":"96e4ac096f3de999","repo":"clockworklabs/SpacetimeDB","slug":"changecolumnaccessorname-table-name-not-found","errorCode":null,"errorMessage":"ChangeColumnAccessorName: `{table_name}` not found in new module def","messagePattern":"ChangeColumnAccessorName: `(.+?)` not found in new module def","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/engine/src/update.rs","lineNumber":390,"sourceCode":"                    plan.new.find_table(table_name_key).ok_or_else(|| {\n                        anyhow::anyhow!(\"ChangeTableAccessorName: `{table_name}` not found in new module def\")\n                    })?;\n\n                let table_id = stdb.table_id_from_name_mut(tx, &table_name)?.unwrap();\n                let new_alias = namespace.join(new_table_def.accessor_name.clone());\n\n                log!(\n                    logger,\n                    \"Changing table accessor name for `{table_name}` to `{new_alias}`\",\n                );\n                stdb.alter_table_accessor_name(tx, table_id, new_alias)?;\n            }\n            spacetimedb_schema::auto_migrate::AutoMigrateStep::ChangeColumnAccessorName(table_name_key, col_name) => {\n                let (namespace, local) = table_name_key;\n                let table_name = joined(namespace, local);\n                let (_, new_table_def): (&ModuleDef, &spacetimedb_schema::def::TableDef) =\n                    plan.new.find_table(table_name_key).ok_or_else(|| {\n                        anyhow::anyhow!(\"ChangeColumnAccessorName: `{table_name}` not found in new module def\")\n                    })?;\n                let new_col_def = new_table_def\n                    .columns\n                    .iter()\n                    .find(|col| &col.name == col_name)\n                    .ok_or_else(|| anyhow::anyhow!(\"Column `{col_name}` not found in table `{table_name}`\"))?;\n\n                let table_id = stdb.table_id_from_name_mut(tx, &table_name)?.unwrap();\n                let table_schema = stdb.schema_for_table_mut(tx, table_id)?;\n                let col_schema = table_schema\n                    .columns\n                    .iter()\n                    .find(|col| &col.col_name == col_name)\n                    .ok_or_else(|| anyhow::anyhow!(\"Column `{col_name}` not found in table `{table_name}`\"))?;\n\n                log!(\n                    logger,\n                    \"Changing column accessor name for `{}`.`{}` to `{}`\",","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/engine/src/update.rs#L372-L408","documentation":"Thrown while applying AutoMigrateStep::ChangeColumnAccessorName: the plan renames a column's accessor (the field alias used by module code) but plan.new.find_table((namespace, local)) fails, so the column list to search cannot even be obtained. The migration step's table key does not resolve in the new module definition the engine is applying against - plan and defs are inconsistent. The update aborts with no changes applied for this step.","triggerScenarios":"Publishing a build where a column accessor changed while its table was also renamed, moved to a submodule, or removed, so the table key no longer matches; or the new module def differs from what the planner diffed (stale target/ artifacts, mismatched compiler/SDK versions).","commonSituations":"Field renames bundled with table refactors; teams publishing the same database from machines with different spacetimedb toolchain versions; leftover target/ directories after toolchain upgrades.","solutions":["Clean-rebuild and republish: cargo clean -p <module-crate> (or remove target/), spacetime build, spacetime publish <db>.","Split the publish: first change only the column accessor (table stored name and module path untouched), then apply the table rename/move in a second publish.","Pin the table's stored name with #[spacetimedb::table(name = \"...\")] so the planner's (namespace, local) key stays stable across refactors.","Make SDK, CLI, and server versions identical to those that published the live database.","On dev databases: spacetime publish --delete-data <db> recreates the schema without auto-migration.","Reproduces on clean builds? File a SpacetimeDB issue with the module diff - planner invariant violation."],"exampleFix":"// before: one publish renames the column accessor AND moves the table\nmod guild {\n    #[spacetimedb::table(name = \"members\")]\n    pub struct Member { pub life: u32 } // field was `hp`\n}\n\n// after: two publishes\n// 1) accessor-only change, table untouched\n#[spacetimedb::table(name = \"players\")]\npub struct Player { pub life: u32 } // was `hp`\n// 2) then publish the table move separately","handlingStrategy":"validation","validationCode":"use spacetimedb_schema::auto_migrate::AutoMigrateStep;\nfor step in &plan.steps {\n    if let AutoMigrateStep::ChangeColumnAccessorName(key, _) = step {\n        if plan.new.find_table(key).is_none() {\n            anyhow::bail!(\"plan step references table {:?} missing from new module def\", key);\n        }\n    }\n}","typeGuard":"fn table_resolves_in_new_def(plan: &AutoMigratePlan, key: (&str, &str)) -> bool {\n    plan.new.find_table(key).is_some()\n}","tryCatchPattern":"match update_database(&stdb, tx, &plan, ...).await {\n    Err(e) if e.to_string().contains(\"ChangeColumnAccessorName\")\n        && e.to_string().contains(\"not found in new module def\") => {\n        // Split the publish: accessor rename first, table rename/move later.\n    }\n    result => result?,\n}","preventionTips":["Keep the table's stored name and module path stable when renaming column accessors.","Pin names with #[table(name = ...)] and #[column(name = ...)].","One logical schema change per publish.","Delete target/ and rebuild after toolchain changes before publishing."],"tags":["spacetimedb","rust","schema-migration","publish","column-rename","accessor"],"backgroundTag":"schema-migration-plan-mismatch","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}