clockworklabs/SpacetimeDB · error · syn::Error
scheduled tables must have a `#[primary_key] #[auto_inc] sch
Error message
scheduled tables must have a `#[primary_key] #[auto_inc] scheduled_id: u64` column
What it means
Scheduled-table validation found a `scheduled_at` time column but no `#[primary_key] #[auto_inc] scheduled_id: u64` column, which the scheduler requires as its handle. The error is emitted at the `scheduled` argument's span and names the exact required column, attributes, and type.
Source
Thrown at crates/bindings-macro/src/table.rs:1104
return Err(syn::Error::new(
sched.span,
"scheduled table missing required columns; add these to your struct:\n\
#[primary_key]\n\
#[auto_inc]\n\
scheduled_id: u64,\n\
scheduled_at: spacetimedb::ScheduleAt,",
));
}
let scheduled_at_column = scheduled_at_column.ok_or_else(|| {
syn::Error::new(
sched.span,
"scheduled tables must have a `scheduled_at: spacetimedb::ScheduleAt` column. \
if the column has a name besides `scheduled_at`, you can specify it with \
`scheduled(my_reducer, at = custom_scheduled_at)`",
)
})?;
let primary_key_column = primary_key_column.ok_or_else(|| {
syn::Error::new(
sched.span,
"scheduled tables must have a `#[primary_key] #[auto_inc] scheduled_id: u64` column",
)
})?;
let reducer_or_procedure = &sched.reducer_or_procedure;
let scheduled_at_id = scheduled_at_column.index;
let desc = quote!(spacetimedb::table::ScheduleDesc {
reducer_or_procedure_name: <#reducer_or_procedure as spacetimedb::rt::FnInfo>::NAME,
scheduled_at_column: #scheduled_at_id,
});
let primary_key_ty = primary_key_column.ty;
let scheduled_at_ty = scheduled_at_column.ty;
let typecheck = quote! {
spacetimedb::rt::scheduled_typecheck::<
#original_struct_ident,
<#reducer_or_procedure as spacetimedb::rt::FnInfo>::FnKind,View on GitHub (pinned to 524b4487d9)
Solutions
- Add `#[primary_key] #[auto_inc] scheduled_id: u64` to the struct
- If the id column was renamed, restore the name `scheduled_id`
- Ensure all three requirements are present: both attributes and the `u64` type
Example fix
// before
#[spacetimedb::table(accessor = reminders, scheduled(run_reminders))]
struct Reminders {
scheduled_at: spacetimedb::ScheduleAt,
note: String,
}
// after
#[spacetimedb::table(accessor = reminders, scheduled(run_reminders))]
struct Reminders {
#[primary_key]
#[auto_inc]
scheduled_id: u64,
scheduled_at: spacetimedb::ScheduleAt,
note: String,
} Defensive patterns
Strategy: validation
Validate before calling
# scheduled tables missing the id column
grep -rl 'scheduled(' src/ | xargs -r grep -L 'scheduled_id' || echo OK Prevention
- Always include `#[primary_key] #[auto_inc] scheduled_id: u64` in scheduled tables
- Do not rename scheduled_id — the scheduler requires the standard shape
- Start from the template rather than hand-writing scheduler schemas
When it happens
Trigger: A scheduled table where `scheduled_at` (or an `at = ...` column) resolves but no primary-key column exists.
Common situations: Removing or renaming `scheduled_id`, or forgetting the `#[primary_key]`/`#[auto_inc]` attributes when hand-writing a scheduled table.
Related errors
- scheduled table missing required columns; add these to your
- scheduled tables must have a `scheduled_at: spacetimedb::Sch
- unions not supported
- must specify table accessor, e.g. `#[spacetimedb::table(acce
- a direct index must be paired with a `#[unique] constraint
AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16).
Data as JSON: /api/errors/e9a307664aef1bef.
Report an issue: GitHub.