use autoincrement id's everywhere #6

Closed
opened 2026-03-19 19:54:34 +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 #6: Use Autoincrement IDs Everywhere

Objective

Replace all UUID v4 string-based IDs with SQLite INTEGER PRIMARY KEY AUTOINCREMENT (u64) IDs across every layer: server (db, models, handlers), OpenRPC spec, SDK, UI dashboard, and web crate.

Current State

All entities (Workspace, User, Channel, Message, Document, Attachment, Room, Group, Mention) use uuid::Uuid::new_v4().to_string(). The only exception is ActivityLogEntry.id which already uses i64.

Implementation Plan (10 Steps)

  1. Update Database Schema (db.rs) - Change all TEXT PRIMARY KEY to INTEGER PRIMARY KEY AUTOINCREMENT, all FK columns from TEXT to INTEGER
  2. Update Server Models (models.rs) - Change all id: String to id: u64, all FK fields from String to u64
  3. Update Server Handlers - Create Methods - Remove UUID generation, use last_insert_rowid(), change param parsing from as_str() to as_u64()
  4. Update Permissions and Supporting Handlers - permissions.rs, read.rs, thread.rs, presence.rs, mention.rs
  5. Update OpenRPC Specification - Change all id schema properties from "type": "string" to "type": "integer"
  6. Update SDK Client - Change all model structs and method signatures to use u64
  7. Update UI Dashboard JavaScript - Adjust onclick handlers for numeric IDs
  8. Update Web Crate Embedded HTML/JS - Same adjustments for the web frontend
  9. Remove uuid Dependency - Remove from all Cargo.toml files
  10. Build and Test - cargo build, cargo test, manual smoke test

Acceptance Criteria

  • All SQLite tables use INTEGER PRIMARY KEY AUTOINCREMENT
  • All Rust model structs use u64 for id and FK fields
  • All handlers use last_insert_rowid() and as_u64()
  • OpenRPC spec declares all ID fields as "type": "integer"
  • SDK uses u64 for all ID parameters and struct fields
  • UI and web JS handle numeric IDs correctly
  • uuid crate dependency removed
  • cargo build --workspace and cargo test --workspace pass

Notes

  • Breaking change: existing databases must be deleted and recreated
  • No migration path for UUID-based data
## Implementation Spec for Issue #6: Use Autoincrement IDs Everywhere ### Objective Replace all UUID v4 string-based IDs with SQLite `INTEGER PRIMARY KEY AUTOINCREMENT` (u64) IDs across every layer: server (db, models, handlers), OpenRPC spec, SDK, UI dashboard, and web crate. ### Current State All entities (Workspace, User, Channel, Message, Document, Attachment, Room, Group, Mention) use `uuid::Uuid::new_v4().to_string()`. The only exception is `ActivityLogEntry.id` which already uses `i64`. ### Implementation Plan (10 Steps) 1. **Update Database Schema (db.rs)** - Change all `TEXT PRIMARY KEY` to `INTEGER PRIMARY KEY AUTOINCREMENT`, all FK columns from `TEXT` to `INTEGER` 2. **Update Server Models (models.rs)** - Change all `id: String` to `id: u64`, all FK fields from `String` to `u64` 3. **Update Server Handlers - Create Methods** - Remove UUID generation, use `last_insert_rowid()`, change param parsing from `as_str()` to `as_u64()` 4. **Update Permissions and Supporting Handlers** - permissions.rs, read.rs, thread.rs, presence.rs, mention.rs 5. **Update OpenRPC Specification** - Change all id schema properties from `"type": "string"` to `"type": "integer"` 6. **Update SDK Client** - Change all model structs and method signatures to use `u64` 7. **Update UI Dashboard JavaScript** - Adjust onclick handlers for numeric IDs 8. **Update Web Crate Embedded HTML/JS** - Same adjustments for the web frontend 9. **Remove uuid Dependency** - Remove from all Cargo.toml files 10. **Build and Test** - cargo build, cargo test, manual smoke test ### Acceptance Criteria - [ ] All SQLite tables use `INTEGER PRIMARY KEY AUTOINCREMENT` - [ ] All Rust model structs use `u64` for id and FK fields - [ ] All handlers use `last_insert_rowid()` and `as_u64()` - [ ] OpenRPC spec declares all ID fields as `"type": "integer"` - [ ] SDK uses `u64` for all ID parameters and struct fields - [ ] UI and web JS handle numeric IDs correctly - [ ] `uuid` crate dependency removed - [ ] `cargo build --workspace` and `cargo test --workspace` pass ### Notes - **Breaking change**: existing databases must be deleted and recreated - **No migration path** for UUID-based data
Author
Owner

Test Results

  • Total: 4
  • Passed: 4
  • Failed: 0
  • cargo build --workspace Clean build
  • cargo test --workspace All tests pass

Implementation Summary

Changes Made

All UUID-based string IDs have been replaced with autoincrement u64 IDs across the entire codebase:

Database (db.rs)

  • All TEXT PRIMARY KEYINTEGER PRIMARY KEY AUTOINCREMENT
  • All FK columns from TEXTINTEGER

Models (models.rs)

  • All id: Stringid: u64
  • All FK String fields → u64 / Option<u64> / Vec<u64>

Handlers (8 entity handlers + 5 supporting handlers)

  • Removed all uuid::Uuid::new_v4() generation
  • Create handlers use last_insert_rowid() for autoincrement IDs
  • All param extraction from as_str()as_u64()
  • All SQL row reading updated for integer types

OpenRPC Spec (openrpc.json)

  • All ID schema properties from "type": "string""type": "integer"

SDK (lib.rs)

  • All model structs and client method signatures updated to use u64

UI Dashboard (dashboard.js)

  • onclick handlers updated for numeric IDs (removed string quotes)
  • DOM value reads wrapped with Number() for RPC calls

Web Crate (main.rs)

  • onclick handlers updated for numeric IDs
  • DOM/localStorage reads wrapped with Number()

Dependencies

  • uuid crate removed from all Cargo.toml files

Notes

  • This is a breaking change — existing databases must be deleted and recreated
  • No migration path for UUID-based data
## Test Results - Total: 4 - Passed: 4 - Failed: 0 - `cargo build --workspace` ✅ Clean build - `cargo test --workspace` ✅ All tests pass ## Implementation Summary ### Changes Made All UUID-based string IDs have been replaced with autoincrement u64 IDs across the entire codebase: **Database (db.rs)** - All `TEXT PRIMARY KEY` → `INTEGER PRIMARY KEY AUTOINCREMENT` - All FK columns from `TEXT` → `INTEGER` **Models (models.rs)** - All `id: String` → `id: u64` - All FK String fields → `u64` / `Option<u64>` / `Vec<u64>` **Handlers (8 entity handlers + 5 supporting handlers)** - Removed all `uuid::Uuid::new_v4()` generation - Create handlers use `last_insert_rowid()` for autoincrement IDs - All param extraction from `as_str()` → `as_u64()` - All SQL row reading updated for integer types **OpenRPC Spec (openrpc.json)** - All ID schema properties from `"type": "string"` → `"type": "integer"` **SDK (lib.rs)** - All model structs and client method signatures updated to use `u64` **UI Dashboard (dashboard.js)** - onclick handlers updated for numeric IDs (removed string quotes) - DOM value reads wrapped with `Number()` for RPC calls **Web Crate (main.rs)** - onclick handlers updated for numeric IDs - DOM/localStorage reads wrapped with `Number()` **Dependencies** - `uuid` crate removed from all Cargo.toml files ### Notes - This is a breaking change — existing databases must be deleted and recreated - No migration path for UUID-based data
Author
Owner

Implementation committed: 7035269

Browse: 7035269

Implementation committed: `7035269` Browse: https://forge.ourworld.tf/lhumina_code/hero_collab/commit/7035269
Sign in to join this conversation.
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_collab#6
No description provided.