{"record":{"id":"e9a307664aef1bef","repo":"clockworklabs/SpacetimeDB","slug":"scheduled-tables-must-have-a-primary-key-aut","errorCode":null,"errorMessage":"scheduled tables must have a `#[primary_key] #[auto_inc] scheduled_id: u64` column","messagePattern":"scheduled tables must have a `#\\[primary_key\\] #\\[auto_inc\\] scheduled_id: u64` column","errorType":"exception","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bindings-macro/src/table.rs","lineNumber":1104,"sourceCode":"                return Err(syn::Error::new(\n                    sched.span,\n                    \"scheduled table missing required columns; add these to your struct:\\n\\\n                             #[primary_key]\\n\\\n                             #[auto_inc]\\n\\\n                             scheduled_id: u64,\\n\\\n                             scheduled_at: spacetimedb::ScheduleAt,\",\n                ));\n            }\n            let scheduled_at_column = scheduled_at_column.ok_or_else(|| {\n                syn::Error::new(\n                    sched.span,\n                    \"scheduled tables must have a `scheduled_at: spacetimedb::ScheduleAt` column. \\\n                             if the column has a name besides `scheduled_at`, you can specify it with \\\n                             `scheduled(my_reducer, at = custom_scheduled_at)`\",\n                )\n            })?;\n            let primary_key_column = primary_key_column.ok_or_else(|| {\n                syn::Error::new(\n                    sched.span,\n                    \"scheduled tables must have a `#[primary_key] #[auto_inc] scheduled_id: u64` column\",\n                )\n            })?;\n\n            let reducer_or_procedure = &sched.reducer_or_procedure;\n            let scheduled_at_id = scheduled_at_column.index;\n            let desc = quote!(spacetimedb::table::ScheduleDesc {\n                reducer_or_procedure_name: <#reducer_or_procedure as spacetimedb::rt::FnInfo>::NAME,\n                scheduled_at_column: #scheduled_at_id,\n            });\n\n            let primary_key_ty = primary_key_column.ty;\n            let scheduled_at_ty = scheduled_at_column.ty;\n            let typecheck = quote! {\n                spacetimedb::rt::scheduled_typecheck::<\n                    #original_struct_ident,\n                    <#reducer_or_procedure as spacetimedb::rt::FnInfo>::FnKind,","sourceCodeStart":1086,"sourceCodeEnd":1122,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-macro/src/table.rs#L1086-L1122","documentation":"Compile-time error from the #[spacetimedb::table] procedural macro. A table declared with the scheduled = <reducer> argument is the persistence backing of a scheduled reducer, and the runtime requires it to carry an auto-incrementing primary key named scheduled_id of type u64. When the macro walks the struct's columns and finds none annotated with both #[primary_key] and #[auto_inc], it emits this syn::Error at the span of the scheduled(...) attribute and aborts compilation. The same code path separately requires a scheduled_at: spacetimedb::ScheduleAt column (customizable via at = ...).","triggerScenarios":"Declaring #[spacetimedb::table(scheduled = my_reducer)] on a struct that has no scheduled_id column, or one that misses #[primary_key] or #[auto_inc], uses a different name (id) or type (u32), or applies only one of the two required field attributes.","commonSituations":"Writing a first scheduled table by copying a plain table and only adding the scheduled argument; following an outdated tutorial or AI-generated example that omits the id column; upgrading SpacetimeDB versions where scheduled-table column requirements changed.","solutions":["Add a #[primary_key] #[auto_inc] scheduled_id: u64 field to the scheduled table struct.","Ensure the column is exactly scheduled_id of type u64 with both field attributes present (not id, not u32, not a single attribute).","Also verify the scheduled_at: spacetimedb::ScheduleAt column exists - the macro raises a parallel diagnostic for it right before this one; fix both before rebuilding."],"exampleFix":"// before\n#[spacetimedb::table(scheduled = tick)]\nstruct Tick {\n    at: spacetimedb::ScheduleAt,\n}\n\n// after\n#[spacetimedb::table(scheduled = tick)]\nstruct Tick {\n    #[primary_key]\n    #[auto_inc]\n    scheduled_id: u64,\n    scheduled_at: spacetimedb::ScheduleAt,\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding scheduled = ... to a table, immediately add both required columns: #[primary_key] #[auto_inc] scheduled_id: u64 and scheduled_at: spacetimedb::ScheduleAt.","Keep a known-good scheduled table in the project as a template and copy it when creating new ones.","Fix both macro diagnostics (missing scheduled_at and missing scheduled_id) in one pass before rebuilding."],"tags":["rust","proc-macro","spacetimedb","scheduled-table","compile-time"],"backgroundTag":"missing-required-table-column","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}