clockworklabs/SpacetimeDB · error
RemoveSequence: `{sequence_name}` not found in old module de
Error message
RemoveSequence: `{sequence_name}` not found in old module def What it means
Dropping a sequence: plan.old.find_storing_table cannot find the owning table in the old module def, although the diff planned the removal. The old-def reconstruction disagrees with the database's actual history - the sequence existed in the database but not under a key the old def can resolve. The publish aborts.
Source
Thrown at crates/engine/src/update.rs:524
anyhow::anyhow!("AddSequence: sequence `{sequence_name}` not found in new module def")
})?;
let table_id = stdb.table_id_from_name_mut(tx, &table_full_name)?.unwrap();
let table_schema = stdb.schema_for_table_mut(tx, table_id)?;
log!(logger, "Adding sequence `{sequence_name}` to table `{table_full_name}`");
let mut sequence_schema =
SequenceSchema::from_module_def(owning_def, sequence_def, table_schema.table_id, 0.into());
// Apply namespace prefix for submodule sequences
sequence_schema.sequence_name = namespace.join_raw(&sequence_schema.sequence_name);
stdb.create_sequence(tx, sequence_schema)?;
}
spacetimedb_schema::auto_migrate::AutoMigrateStep::RemoveSequence(key) => {
let (namespace, sequence_name) = key;
let (_owning_def, table_def) = plan
.old
.find_storing_table(namespace, sequence_name)
.ok_or_else(|| anyhow::anyhow!("RemoveSequence: `{sequence_name}` not found in old module def"))?;
let table_full_name = joined(namespace, &table_def.name);
let stored_name = namespace.join_raw(&sequence_name.clone().into());
let table_id = stdb.table_id_from_name_mut(tx, &table_full_name)?.unwrap();
let table_schema = stdb.schema_for_table_mut(tx, table_id)?;
let sequence_schema = table_schema
.sequences
.iter()
.find(|sequence| sequence.sequence_name == stored_name)
.unwrap();
log!(
logger,
"Dropping sequence `{sequence_name}` from table `{table_full_name}`"
);
stdb.drop_sequence(tx, sequence_schema.sequence_id)?;
}
spacetimedb_schema::auto_migrate::AutoMigrateStep::ChangeColumns(table_name_key) => {
let (namespace, local) = table_name_key;View on GitHub (pinned to 6dee26c6ef)
Solutions
- Clean-rebuild and republish.
- Remove the auto_inc column in its own publish; rename/move the table in another.
- Keep table names pinned across the versions involved.
- Match the toolchain that published the live database before removing sequences.
- Dev: spacetime publish --delete-data <db>.
- Report with the sequence and table names if it persists.
Example fix
// before: drop #[auto_inc] and rename the table in one publish
#[spacetimedb::table(name = "members")] // was `players`
pub struct Member { pub id: u64 } // #[auto_inc] removed
// after: two publishes
// 1) remove #[auto_inc] only, name still `players`
// 2) rename the table separately Defensive patterns
Strategy: fallback
Validate before calling
use spacetimedb_schema::auto_migrate::AutoMigrateStep;
for step in &plan.steps {
if let AutoMigrateStep::RemoveSequence((namespace, sname)) = step {
if plan.old.find_storing_table(namespace, sname).is_none() {
anyhow::bail!("old def lacks sequence {} - schema drift", sname);
}
}
} Type guard
fn sequence_in_old_def(plan: &AutoMigratePlan, ns: &str, sname: &str) -> bool {
plan.old.find_storing_table(ns, sname).is_some()
} Try / catch
match update_database(&stdb, tx, &plan, ...).await {
Err(e) if e.to_string().contains("RemoveSequence")
&& e.to_string().contains("old module def") => {
// Fall back: publish the exact prior build, then drop the sequence in its own publish.
}
result => result?,
} Prevention
- Remove auto_inc/sequence columns in a dedicated publish with no renames.
- Keep table names pinned across the versions involved.
- Match the toolchain that published the live database before removing sequences.
- Clean-build between publishes after version changes.
When it happens
Trigger: Removing #[auto_inc] columns/sequences while also renaming the table in the same publish; the database was published by a build with different sequence auto-naming; submodule moves changing the namespace key between publishes.
Common situations: Dropping auto-increment IDs during table renames; version upgrades that changed sequence naming; republishing databases created by older compilers.
Related errors
- AddSequence: `{sequence_name}` not found in new module def
- ChangeTableAccessorName: `{table_name}` not found in new mod
- ChangeColumnAccessorName: `{table_name}` not found in new mo
- Column `{col_name}` not found in table `{table_name}`
- ChangeIndexSourceName: `{index_name}` not found in old modul
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/771ad29b392f9d7e.
Report an issue: GitHub.