Default local storage to Hive with legacy migration

This commit is contained in:
Rijad Zuzo
2026-02-15 19:17:25 +01:00
parent 21c911ad4c
commit 1502360051
8 changed files with 142 additions and 10 deletions
+7 -2
View File
@@ -26,7 +26,8 @@ flutter run --dart-define=USE_FAKE_BACKEND=true
Default local store:
- `shared_preferences` (stable baseline)
- `Hive` (`USE_HIVE_LOCAL_DB=true` by default)
- first-run migration imports legacy `shared_preferences` payload when present
Optional migration path:
@@ -34,7 +35,11 @@ Optional migration path:
flutter run --dart-define=USE_HIVE_LOCAL_DB=true
```
When enabled, local app state is stored in Hive via the `LocalDataStore` adapter layer.
Use legacy mode explicitly if needed:
```bash
flutter run --dart-define=USE_HIVE_LOCAL_DB=false
```
## Run Tests
+8
View File
@@ -20,8 +20,16 @@ Implemented a persistence boundary so local app state is no longer tightly coupl
- schema migration hook retained and now store-agnostic
- Added config flag for local backend selection:
- `lib/core/config/app_config.dart` -> `USE_HIVE_LOCAL_DB`
- default now set to Hive (`true`)
- Added one-time migration path from legacy shared prefs into Hive:
- `lib/features/local/local_repository.dart`
- when Hive is active and empty, legacy payload is imported then cleared
- Added setup docs for switching local persistence backend:
- `docs/SETUP.md`
- Added migration/storage tests:
- `test/features/local/storage/local_data_store_shared_prefs_test.dart`
- `test/features/local/storage/local_repository_store_override_test.dart`
- `test/features/local/storage/local_repository_hive_migration_test.dart`
This prepares the app for a true DB migration path while keeping existing UX and tests stable.