Skip to content

T-3: SQLite persistence via sqlx — migrations and CRUD#58

Merged
kirich1409 merged 5 commits intomainfrom
feature/t3-sqlx-store
Apr 13, 2026
Merged

T-3: SQLite persistence via sqlx — migrations and CRUD#58
kirich1409 merged 5 commits intomainfrom
feature/t3-sqlx-store

Conversation

@kirich1409
Copy link
Copy Markdown
Contributor

Summary

  • Add sqlx 0.8 (sqlite, runtime-tokio-rustls, macros, uuid, chrono) to runner/
  • Three migration files: projects, workspaces, sessions tables with soft-delete (deleted_at), FK indices, WAL mode enabled at pool-open time via SqliteJournalMode::Wal
  • runner/src/store.rs: Store struct with full async CRUD for Project, Workspace, Session domain types; row types kept internal, mapped to domain types at DB boundary
  • Optimistic concurrency on update_project_state / update_session_state via WHERE updated_at = ? check — returns bool (false = stale or not found)
  • 7 unit tests covering: WAL mode verified via PRAGMA, create/get, list-excluding-soft-deleted, optimistic concurrency conflict for projects and sessions, idempotent soft-delete
  • SQLX_OFFLINE=true works: dynamic query() / query_as::<_, Row>() calls require no compile-time cache; .sqlx/sqlx-data.json committed

Acceptance criteria

  • sqlx migrate run applies all migrations without errors
  • CRUD operations for projects, workspaces, sessions — unit tests pass
  • WAL mode enabled (PRAGMA journal_mode=WAL) — verified in test
  • Transactional state update with optimistic concurrency (updated_at check)
  • .sqlx/ cache generated, SQLX_OFFLINE=true works in CI
  • cargo test passes including sqlx offline mode

Closes #17

Copilot AI review requested due to automatic review settings April 13, 2026 13:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and sessions (soft-delete via deleted_at, indexes).
  • Add sqlx + chrono dependencies 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.

Comment thread runner/src/store.rs
Comment thread runner/src/store.rs
Comment thread runner/src/store.rs
Comment thread runner/src/store.rs
Comment thread runner/src/store.rs
Comment thread runner/src/store.rs
Comment thread runner/src/store.rs
Copilot AI review requested due to automatic review settings April 13, 2026 13:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread runner/src/store.rs
Comment thread runner/Cargo.toml
Comment thread runner/.cargo/audit.toml
Comment thread runner/Cargo.toml
- 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
@kirich1409 kirich1409 force-pushed the feature/t3-sqlx-store branch from 2b42aeb to 10ea61c Compare April 13, 2026 14:00
Copilot AI review requested due to automatic review settings April 13, 2026 14:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread runner/src/store.rs Outdated
Comment thread runner/.cargo/audit.toml
@kirich1409 kirich1409 merged commit f3a4351 into main Apr 13, 2026
10 checks passed
@kirich1409 kirich1409 deleted the feature/t3-sqlx-store branch April 13, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T-3: SQLite через sqlx — миграции, таблицы, CRUD

2 participants