id;s are u64 #3

Open
opened 2026-03-19 19:52:57 +00:00 by despiegk · 3 comments
Owner

as id's use autocincrement u64 everywhere not long guids

make sure the _server,_ui, _web (if it exists), the openrpc, the sdk all gets changed to use incremental id's for everything

as id's use autocincrement u64 everywhere not long guids make sure the _server,_ui, _web (if it exists), the openrpc, the sdk all gets changed to use incremental id's for everything
Author
Owner

Implementation Spec for Issue #3: IDs are u64

Objective

Replace all string-based UUID/GUID primary keys with autoincrement u64 (INTEGER PRIMARY KEY AUTOINCREMENT in SQLite) across the entire stack: database schema, server models, server handlers, OpenRPC spec, SDK client, admin UI, and end-user web UI.

Requirements

  • All entity tables use INTEGER PRIMARY KEY AUTOINCREMENT instead of TEXT PRIMARY KEY
  • All foreign key columns referencing IDs change from TEXT to INTEGER
  • Server no longer depends on the uuid crate
  • OpenRPC spec reflects integer types for all ID fields
  • SDK methods accept u64 for ID parameters
  • Web frontend does not generate client-side IDs; server assigns all IDs via autoincrement
  • Admin UI works with integer IDs
  • board_shares table gets integer PK + token TEXT UNIQUE column

Implementation Plan (10 Steps)

  1. Create new database migration — Drop/recreate all tables with INTEGER PRIMARY KEY AUTOINCREMENT
  2. Update server models — Change all id: String to id: u64 in model structs
  3. Update server queries — Adapt SQL queries, use last_insert_rowid(), change param types
  4. Update server handlers — Replace as_str() with as_u64(), remove UUID generation
  5. Update OpenRPC specification — Change all ID fields from "type": "string" to "type": "integer"
  6. Update SDK client — Change convenience method parameter types from &str to u64
  7. Update web frontend JavaScript — Remove client-side ID generation, use server-assigned IDs
  8. Update web crate Rust routes — Change Path<String> to Path<u64> for board routes
  9. Remove uuid dependency from workspace Cargo.toml
  10. Build, test, and verify

Acceptance Criteria

  • All database tables use INTEGER PRIMARY KEY AUTOINCREMENT
  • All FK columns use INTEGER type
  • uuid crate removed
  • OpenRPC spec defines all ID fields as "type": "integer"
  • Server handlers parse IDs with as_u64()
  • SDK accepts u64 for ID params
  • Web frontend relies on server-assigned integer IDs
  • Board URLs use integer IDs (e.g., /board/42)
  • Share links continue to work (token-based)
  • Project compiles and tests pass

Notes

  • Migration is destructive (early development, acceptable)
  • Client-side JS will use negative temp IDs during async gap before server response
  • DEFAULT_WORKSPACE_ID changes from "default" to 1u64
  • board_shares gets integer PK + separate token column
  • Composite PK tables just need FK column types changed
## Implementation Spec for Issue #3: IDs are u64 ### Objective Replace all string-based UUID/GUID primary keys with autoincrement `u64` (`INTEGER PRIMARY KEY AUTOINCREMENT` in SQLite) across the entire stack: database schema, server models, server handlers, OpenRPC spec, SDK client, admin UI, and end-user web UI. ### Requirements - All entity tables use `INTEGER PRIMARY KEY AUTOINCREMENT` instead of `TEXT PRIMARY KEY` - All foreign key columns referencing IDs change from `TEXT` to `INTEGER` - Server no longer depends on the `uuid` crate - OpenRPC spec reflects `integer` types for all ID fields - SDK methods accept `u64` for ID parameters - Web frontend does not generate client-side IDs; server assigns all IDs via autoincrement - Admin UI works with integer IDs - `board_shares` table gets integer PK + `token TEXT UNIQUE` column ### Implementation Plan (10 Steps) 1. **Create new database migration** — Drop/recreate all tables with `INTEGER PRIMARY KEY AUTOINCREMENT` 2. **Update server models** — Change all `id: String` to `id: u64` in model structs 3. **Update server queries** — Adapt SQL queries, use `last_insert_rowid()`, change param types 4. **Update server handlers** — Replace `as_str()` with `as_u64()`, remove UUID generation 5. **Update OpenRPC specification** — Change all ID fields from `"type": "string"` to `"type": "integer"` 6. **Update SDK client** — Change convenience method parameter types from `&str` to `u64` 7. **Update web frontend JavaScript** — Remove client-side ID generation, use server-assigned IDs 8. **Update web crate Rust routes** — Change `Path<String>` to `Path<u64>` for board routes 9. **Remove uuid dependency** from workspace Cargo.toml 10. **Build, test, and verify** ### Acceptance Criteria - [ ] All database tables use `INTEGER PRIMARY KEY AUTOINCREMENT` - [ ] All FK columns use `INTEGER` type - [ ] `uuid` crate removed - [ ] OpenRPC spec defines all ID fields as `"type": "integer"` - [ ] Server handlers parse IDs with `as_u64()` - [ ] SDK accepts `u64` for ID params - [ ] Web frontend relies on server-assigned integer IDs - [ ] Board URLs use integer IDs (e.g., `/board/42`) - [ ] Share links continue to work (token-based) - [ ] Project compiles and tests pass ### Notes - Migration is destructive (early development, acceptable) - Client-side JS will use negative temp IDs during async gap before server response - `DEFAULT_WORKSPACE_ID` changes from `"default"` to `1u64` - `board_shares` gets integer PK + separate `token` column - Composite PK tables just need FK column types changed
Author
Owner

Build & Test Results

  • cargo build --workspace: Passed
  • cargo test --workspace: Passed (all tests pass)

Issues Found & Fixed During Build

  • crates/hero_whiteboard_examples/examples/basic_usage.rs — was still using as_str() for ID extraction; updated to as_u64() to match the new u64 ID types

Changes Summary

All ID fields across the stack have been migrated from String/UUID to u64 autoincrement:

  • Database migration (004_u64_ids.sql) — all tables recreated with INTEGER PRIMARY KEY AUTOINCREMENT
  • Server models — all id: Stringid: u64
  • Server queries — all functions updated for u64 params, last_insert_rowid()
  • Server handlers — all ID parsing changed from as_str() to as_u64()
  • OpenRPC spec — all ID fields changed from "type": "string" to "type": "integer"
  • SDK — all ID params changed from &str to u64
  • Web routes — Path → Path for board routes
  • Frontend JavaScript — client-side ID generation replaced with server-assigned integer IDs
  • Examples — updated to use u64 IDs
## Build & Test Results - **`cargo build --workspace`**: ✅ Passed - **`cargo test --workspace`**: ✅ Passed (all tests pass) ### Issues Found & Fixed During Build - `crates/hero_whiteboard_examples/examples/basic_usage.rs` — was still using `as_str()` for ID extraction; updated to `as_u64()` to match the new u64 ID types ### Changes Summary All ID fields across the stack have been migrated from String/UUID to u64 autoincrement: - Database migration (004_u64_ids.sql) — all tables recreated with INTEGER PRIMARY KEY AUTOINCREMENT - Server models — all `id: String` → `id: u64` - Server queries — all functions updated for u64 params, last_insert_rowid() - Server handlers — all ID parsing changed from as_str() to as_u64() - OpenRPC spec — all ID fields changed from "type": "string" to "type": "integer" - SDK — all ID params changed from &str to u64 - Web routes — Path<String> → Path<u64> for board routes - Frontend JavaScript — client-side ID generation replaced with server-assigned integer IDs - Examples — updated to use u64 IDs
Author
Owner

Implementation committed: a232f127ddf024e962e3e2d4203dc9d8a3a65808

Browse: a232f127dd

Implementation committed: `a232f127ddf024e962e3e2d4203dc9d8a3a65808` Browse: https://forge.ourworld.tf/lhumina_code/hero_whiteboard/commit/a232f127ddf024e962e3e2d4203dc9d8a3a65808
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_whiteboard#3
No description provided.