SQLite persistence — EventStore & migrations #5
Labels
No labels
area:config
area:contracts
area:engine
area:eventsourcing
area:frontend
area:git
area:ipc
area:persistence
area:provider
area:scaffold
area:terminal
type:user-story
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/peon#5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
User story
As a backend developer, I want an SQLite-backed EventStore that persists domain events atomically and supports full replay at startup, plus denormalized projection tables for fast reads, so that application state survives restarts.
Acceptance criteria
Database schema (
migrations/001_initial.sql)eventstable:sequence INTEGER PRIMARY KEY AUTOINCREMENT,event_type TEXT NOT NULL,payload TEXT NOT NULL(JSON),stored_at TEXT NOT NULL(ISO 8601)projection_projectstable with columns matching spec §12.1projection_threadstable with columns matching spec §12.1projection_turnstable with columns matching spec §12.1projection_messagestable with columns matching spec §12.1checkpointstable with columns matching spec §12.1settingstable:key TEXT PRIMARY KEY,value TEXT NOT NULL(JSON)idx_events_sequence,idx_turns_thread,idx_messages_turnMigration runner
sqlx::migrate!)AppConfig.general.data_dir)EventStore (
persistence/event_store.rs)EventStore::new(pool: SqlitePool)constructorappend_all(events: Vec<OrchestrationEvent>) -> Result<Vec<StoredEvent>>— atomic batch insert in a transaction, returns stored events with assigned sequence numbersreplay_all() -> Result<Vec<StoredEvent>>— reads all events ordered by sequence for startup replayreplay_from(sequence: u64) -> Result<Vec<StoredEvent>>— partial replay from a given sequenceOrchestrationEventvia serde for thepayloadcolumnevent_type_name()helper that extracts the variant name as a string for theevent_typecolumnTests
:memory:)Out of scope
References
Dependencies
issue-4-event-sourcing