Switch persistence layer from Realm to SQLite (TypeORM + react-native-sqlite-storage)#139
Draft
Switch persistence layer from Realm to SQLite (TypeORM + react-native-sqlite-storage)#139
Conversation
|
|
…-sqlite-storage) Agent-Logs-Url: https://github.com/SpeedcuberOSS/speedcuber-timer/sessions/eb945153-577f-4a93-ad10-d23a96521db9 Co-authored-by: thehale <47901316+thehale@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Switch from Realm to SQLite database
Switch persistence layer from Realm to SQLite (TypeORM + react-native-sqlite-storage)
Mar 31, 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.
MongoDB Realm is deprecated and being removed in September 2025. This replaces it with TypeORM backed by
react-native-sqlite-storage, which is compatible with React Native 0.71.New:
src/persistence/sqlitedb/entities/AttemptSchema.ts— TypeORMEntitySchemaforSTIF.Attempt. IndexedeventIdandinspectionStartcolumns mirror the existing Realm query patterns; complex sub-objects (solutions,infractions,event) stored as JSON text columns. IncludesrowToAttempt/attemptToRowserializers.entities/SolveRecordingSchema.ts— TypeORMEntitySchemaforSTIF.SolveRecording.index.ts—AppDataSourceconfiguration +attemptsVersionglobal counter (viareact-hooks-global-state, already a dependency) that replaces Realm's live-query observation: hooks re-fetch whenever a write bumps the counter.DatabaseProvider.tsx— React context provider wrappingDataSourceinitialization; exposesuseDatabase().Updated
src/persistence/hooks/— migrated from Realm APIs to TypeORM repositories.useAttemptRestorationwrapsclear()+save()in a transaction for atomicity.src/ui/App.tsx—RealmProvider→DatabaseProvider; Realm Flipper plugin removed.package.json— removesrealm,@realm/react,realm-flipper-plugin-device; addstypeorm@^0.3.26,react-native-sqlite-storage@^6.0.1.Deleted
src/persistence/realmdb/— replaced entirely.Design notes
EntitySchemathroughout to avoidreflect-metadata/experimentalDecorators, which conflict withisolatedModules: trueintsconfig.json.backup.ts/restore.ts) is unchanged and serves as the migration path for existing users — back up on the old version, restore on the new one.synchronize: trueauto-creates tables on first launch. Future schema changes should switch to TypeORM migrations.