{"record":{"id":"55d2710af0299e9e","repo":"clockworklabs/SpacetimeDB","slug":"changeaccess-table-name-not-found-as-a-table","errorCode":null,"errorMessage":"ChangeAccess: `{table_name}` not found as a table or view in new module def","messagePattern":"ChangeAccess: `(.+?)` not found as a table or view in new module def","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/engine/src/update.rs","lineNumber":574,"sourceCode":"                let table_name = joined(namespace, local);\n                let (owning_def, table_def) = plan.new.find_table(table_name_key).ok_or_else(|| {\n                    anyhow::anyhow!(\"ReschemaEventTable: table `{table_name}` not found in new module def\")\n                })?;\n                let table_id = stdb.table_id_from_name_mut(tx, &table_name).unwrap().unwrap();\n                let column_schemas = column_schemas_from_defs(owning_def, &table_def.columns, table_id);\n\n                log!(logger, \"Changing schema of event table `{}`\", table_name);\n\n                stdb.alter_event_table_row_type(tx, table_id, column_schemas)?;\n            }\n            spacetimedb_schema::auto_migrate::AutoMigrateStep::ChangeAccess(table_name_key) => {\n                let (namespace, local) = table_name_key;\n                let table_name = joined(namespace, local);\n                let access = if let Some((_owning_def, table_def)) = plan.new.find_table(table_name_key) {\n                    table_def.table_access\n                } else {\n                    let (_owning_def, view_def) = plan.new.find_view(table_name_key).ok_or_else(|| {\n                        anyhow::anyhow!(\"ChangeAccess: `{table_name}` not found as a table or view in new module def\")\n                    })?;\n                    if view_def.is_public {\n                        TableAccess::Public\n                    } else {\n                        TableAccess::Private\n                    }\n                };\n                stdb.alter_table_access(tx, &table_name, access.into())?;\n            }\n            spacetimedb_schema::auto_migrate::AutoMigrateStep::ChangePrimaryKey(table_name_key) => {\n                let (namespace, local) = table_name_key;\n                let table_name = joined(namespace, local);\n                let (_owning_def, table_def) = plan.new.find_table(table_name_key).ok_or_else(|| {\n                    anyhow::anyhow!(\"ChangePrimaryKey: table `{table_name}` not found in new module def\")\n                })?;\n                log!(logger, \"Changing primary key for table `{table_name}`\");\n                stdb.alter_table_primary_key(tx, &table_name, table_def.primary_key)?;\n            }","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/engine/src/update.rs#L556-L592","documentation":"Changing a table's or view's access (public/private): the engine looks the entity up first as a table (plan.new.find_table) and then as a view (plan.new.find_view); neither resolves in the new module def. The access-change step references an entity that exists neither as table nor as view in the new defs. The publish aborts.","triggerScenarios":"Toggling public on a table or view while renaming it, deleting it, or converting it between table and view in the same publish, so the (namespace, local) key matches nothing in the new def.","commonSituations":"Making an entity public during a rename refactor; switching an entity from a stored table to a computed view (or vice versa) in one publish.","solutions":["Clean-rebuild and republish.","Change access in its own publish with the entity's name, kind, and location untouched.","Do the rename/move or table-to-view conversion in a separate publish.","Pin names with #[table(name = \"...\")] to keep keys stable.","Dev: spacetime publish --delete-data <db>.","Report persistent cases with the entity declarations."],"exampleFix":"// before: make public + rename in one publish\n#[spacetimedb::table(name = \"members\", public)] // was \"players\", private\npub struct Member {}\n\n// after: two publishes\n// 1) #[spacetimedb::table(name = \"players\", public)]\n// 2) rename to \"members\" afterwards","handlingStrategy":"validation","validationCode":"use spacetimedb_schema::auto_migrate::AutoMigrateStep;\nfor step in &plan.steps {\n    if let AutoMigrateStep::ChangeAccess(key) = step {\n        if plan.new.find_table(key).is_none() && plan.new.find_view(key).is_none() {\n            anyhow::bail!(\"ChangeAccess step references {:?} that is neither table nor view in new def\", key);\n        }\n    }\n}","typeGuard":"fn entity_in_new_def(plan: &AutoMigratePlan, key: (&str, &str)) -> bool {\n    plan.new.find_table(key).is_some() || plan.new.find_view(key).is_some()\n}","tryCatchPattern":"match update_database(&stdb, tx, &plan, ...).await {\n    Err(e) if e.to_string().contains(\"ChangeAccess\") => {\n        // Split: toggle access with the entity unchanged; rename/convert in a later publish.\n    }\n    result => result?,\n}","preventionTips":["Toggle public/private in a dedicated publish.","Do not rename, delete, or convert an entity between table and view while changing its access.","Pin entity names with #[table(name = ...)].","One logical schema change per publish."],"tags":["spacetimedb","rust","schema-migration","access-control","public-private","publish"],"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-14T05:17:10.506Z"}