OfflineDriftDatabase
Component Detail
Description
Provides the on-device relational database layer using Drift (formerly Moor) backed by SQLCipher for AES-256 encryption at rest. Defines all local table schemas, DAOs, and typed query interfaces that mirror the server data model. Manages database migrations and supplies an ID-mapping table for reconciling temporary client-side IDs with server-assigned IDs after sync.
offline-drift-database
Sources & reasoning
Lines 300-304 describe the offline-first architecture explicitly with Drift+SQLCipher, mutation outbox, conflict resolver, and optimistic mutations - these are the precise capabilities this feature implements. Line 185 confirms Drift as the chosen technology. The blueprint assigns MVP, consistent with the source doc's framing of offline-first as a core architectural pattern, not an optional add-on, and the priority matrix placing activity registration as a MUST HAVE in Phase 1.
-
docs/source/likeperson.md · line 185Tech: Flutter, Riverpod (no codegen), Drift (offline), WCAG 2.2 AA
-
docs/source/likeperson.md · line 300-304Offline-first persistence (Drift + SQLCipher encrypted local DB, mutation outbox, sync queue with retry/backoff, ID mapping for offline-created entities, conflict resolver) - Optimistic mutations with automatic rollback on failure (contact edits and
Responsibilities
- Define and migrate encrypted local table schemas using Drift
- Expose typed DAO interfaces for all operational entities
- Maintain an ID-mapping table linking temporary offline IDs to server IDs
- Handle schema version upgrades without data loss
- Provide reactive query streams for UI state synchronisation
Interfaces
getDatabase(): AppDatabase
runMigration(fromVersion: int, toVersion: int): void
mapOfflineId(tempId: string, serverId: string): void
resolveServerId(tempId: string): string?
watchTable<T>(table: TableInfo<T>): Stream<List<T>>
Related Data Entities (1)
Data entities managed by this component