{"record":{"id":"1a241f5252c09789","repo":"clockworklabs/SpacetimeDB","slug":"scheduled-table-missing-required-columns-add-thes","errorCode":null,"errorMessage":"scheduled table missing required columns; add these to your struct:\n#[primary_key]\n#[auto_inc]\nscheduled_id: u64,\nscheduled_at: spacetimedb::ScheduleAt,","messagePattern":"scheduled table missing required columns; add these to your struct:\n#\\[primary_key\\]\n#\\[auto_inc\\]\nscheduled_id: u64,\nscheduled_at: spacetimedb::ScheduleAt,","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bindings-macro/src/table.rs","lineNumber":1086,"sourceCode":"    }).collect();\n\n    let default_fn: TokenStream = quote! {\n        fn get_default_col_values() -> Vec<spacetimedb::table::ColumnDefault> {\n            [#(#col_defaults)*].to_vec()\n        }\n    };\n\n    let (schedule, schedule_typecheck) = args\n        .scheduled\n        .as_ref()\n        .map(|sched| {\n            let scheduled_at_column = match &sched.at {\n                Some(at) => Some(find_column(&columns, at)?),\n                None => try_find_column(&columns, \"scheduled_at\"),\n            };\n            // better error message when both are missing\n            if scheduled_at_column.is_none() && primary_key_column.is_none() {\n                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(","sourceCodeStart":1068,"sourceCodeEnd":1104,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/bindings-macro/src/table.rs#L1068-L1104","documentation":"A table marked `scheduled(...)` must contain both a `#[primary_key] #[auto_inc] scheduled_id: u64` column and a `scheduled_at: spacetimedb::ScheduleAt` column; the scheduler stores its id and firing time in them. When validation finds neither a primary-key column nor any scheduled_at column, this combined guidance is emitted at the `scheduled` argument's span, listing the exact lines to add.","triggerScenarios":"`#[spacetimedb::table(accessor = t, scheduled(reducer))]` on a struct whose fields include neither a `#[primary_key]` column nor a `scheduled_at` (or `at = ...`) column.","commonSituations":"Writing a first scheduled table without starting from the template; deleting or renaming both standard columns while customizing the schema.","solutions":["Add the two required columns exactly as the message shows: `#[primary_key] #[auto_inc] scheduled_id: u64` and `scheduled_at: spacetimedb::ScheduleAt`","Keep the conventional names unless you also pass `at = ...` for the time column","Re-run cargo check to confirm no further scheduled-table errors follow"],"exampleFix":"// before\n#[spacetimedb::table(accessor = ticks, scheduled(run_ticks))]\nstruct Ticks {\n    payload: String,\n}\n\n// after\n#[spacetimedb::table(accessor = ticks, scheduled(run_ticks))]\nstruct Ticks {\n    #[primary_key]\n    #[auto_inc]\n    scheduled_id: u64,\n    scheduled_at: spacetimedb::ScheduleAt,\n    payload: String,\n}","handlingStrategy":"validation","validationCode":"# every scheduled table needs both standard columns\ngrep -rl 'scheduled(' src/ | xargs -r grep -L 'scheduled_id'\ngrep -rl 'scheduled(' src/ | xargs -r grep -L 'scheduled_at'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Start scheduled tables from the documented template containing both required columns","If renaming scheduled_at, immediately add `at = ...` to the scheduled(...) args","Run cargo check right after marking a table scheduled"],"tags":["rust","proc-macro","spacetimedb","scheduled-table","compile-time"],"backgroundTag":"missing-required-schema-fields","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}