T-3: SQLite persistence via sqlx — migrations and CRUD#58
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new SQLite-backed persistence layer to runner/ using sqlx, including schema migrations and async CRUD APIs for Project, Workspace, and Session, plus tests validating WAL mode and optimistic concurrency behavior.
Changes:
- Introduce
Store(sqlx + SQLite pool) with CRUD and optimistic concurrency helpers. - Add SQLite migrations for
projects,workspaces, andsessions(soft-delete viadeleted_at, indexes). - Add
sqlx+chronodependencies and commit a.sqlx/offline cache placeholder.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| runner/src/store.rs | New persistence module: domain types, row mapping, CRUD, optimistic concurrency, and unit tests. |
| runner/src/main.rs | Registers the new store module in the runner crate. |
| runner/migrations/20240001_create_projects.sql | Creates projects table + state index + soft-delete support. |
| runner/migrations/20240002_create_workspaces.sql | Creates workspaces table + project FK index + soft-delete support. |
| runner/migrations/20240003_create_sessions.sql | Creates sessions table + workspace/state indexes + soft-delete support. |
| runner/Cargo.toml | Adds sqlx and chrono dependencies (and uses existing tempfile for tests). |
| runner/Cargo.lock | Locks new transitive dependencies from adding sqlx/chrono. |
| runner/.sqlx/sqlx-data.json | Adds committed sqlx offline metadata file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add sqlx 0.8 (sqlite, runtime-tokio-rustls, macros, uuid, chrono) and chrono 0.4 to runner/Cargo.toml - Create three migration files: projects, workspaces, sessions tables with soft-delete (deleted_at), FK indices, and WAL mode via pool opts - Implement runner/src/store.rs: Store struct wrapping SqlitePool with full CRUD for Project, Workspace, Session domain types - Optimistic concurrency on state updates via updated_at WHERE clause - 7 unit tests: WAL mode, CRUD, soft-delete exclusion, optimistic concurrency for both projects and sessions, idempotent soft-delete - All tests pass with SQLX_OFFLINE=true (dynamic queries, no query! macros) - runner/.sqlx/sqlx-data.json committed for CI offline mode Closes #17
2b42aeb to
10ea61c
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… (via sqlx-mysql)
Summary
sqlx 0.8(sqlite, runtime-tokio-rustls, macros, uuid, chrono) torunner/projects,workspaces,sessionstables with soft-delete (deleted_at), FK indices, WAL mode enabled at pool-open time viaSqliteJournalMode::Walrunner/src/store.rs:Storestruct with full async CRUD forProject,Workspace,Sessiondomain types; row types kept internal, mapped to domain types at DB boundaryupdate_project_state/update_session_stateviaWHERE updated_at = ?check — returnsbool(false = stale or not found)SQLX_OFFLINE=trueworks: dynamicquery()/query_as::<_, Row>()calls require no compile-time cache;.sqlx/sqlx-data.jsoncommittedAcceptance criteria
sqlx migrate runapplies all migrations without errorsPRAGMA journal_mode=WAL) — verified in testupdated_atcheck).sqlx/cache generated,SQLX_OFFLINE=trueworks in CIcargo testpasses including sqlx offline modeCloses #17