feat(db): extract Database trait abstraction layer (Phase 1)#186
Merged
Conversation
Closes #166. Foundation for multi-backend support (#171). Changes: - New crate with generic trait - 40+ methods: projects, issues, events, alerts, search, auth, retention - impl moves all 60+ raw SQL queries out of core - Includes search, count_table, purge, cooldown, ping trait methods - becomes thin facade over - Zero behavior change: same public API, delegates to backend - escape hatch retained for search/mcp/metrics (Phase 3) - delegates to trait methods - / re-exported from - Tests: 84/84 pass across workspace (5 new in trapfall-db) No reference in trait surface. Backend-agnostic foundation ready for Phase 2 (#167: connection factory) and Phase 3 (#168: Postgres).
11 tasks
This was referenced Jun 15, 2026
Merged
ajianaz
added a commit
that referenced
this pull request
Jun 15, 2026
This was referenced Jun 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #166. Foundation for multi-backend DB support (#171).
Extracts all SQLite-specific SQL behind a generic
Databasetrait in new cratetrapfall-db.trapfall-core::Storebecomes a thin facade delegating toArc<dyn Database>.Changes
trapfall-db(crates/trapfall-db/):Databasetrait — 40+ async methods covering all storage operationsSqliteBackend— implements trait, owns all 60+ raw SQL queriesStoredUser/StoredSessionrow typestrapfall-core::store— thin facade overArc<dyn Database>Store::with_backend(Arc<dyn Database>)new constructor for Phase 2Store::pool()escape hatch retained (search/mcp/metrics still raw SQL — Phase 3)trapfall-core::auth— delegates to trait methodsUser/Sessionre-exported fromtrapfall-dbWhy This Approach
Phase 1 goal: foundation without behavior change. Opsi "sempit" dipilih:
Storemethods (the main read/write path)Store::pool()retained as escape hatch fortrapfall-search,trapfall-mcp, retention, metrics yang masih query SQL langsungAlternative wide refactor (all crates via trait) ditolak karena:
Acceptance Criteria (from #166)
trapfall-dbcrate compiles and passes tests (5/5)StoreusesArc<dyn Database>internallyStore::pool()retained for SQLite escape hatch (documented)Test Plan
cargo test --workspaceResult: 84 passed, 0 failed.
Dependencies
Blocks: #167 (Phase 2), #168 (Phase 3), #169 (Phase 4), #170 (Phase 5)
Epic: #171