[native] migrate integrityStore to SQLite
Summary: This implements the web/native migration for the integrityStore table to sqlite
Test Plan:
integrity table on dev environment didn't have prior integrity store thread hashes, so I tested by migrating raw thread hash data.
console.log('running migration 64'); const threadHashes1: ThreadHashes = { thread1: 123, thread2: 456, thread3: 789, }; const threadHashes2: ThreadHashes = { thread1: 893, thread2: 443, thread3: 913, }; const threadHashes3: ThreadHashes = { thread4: 593, }; const replaceOp1: ReplaceIntegrityThreadHashesOperation = { type: 'replace_integrity_thread_hashes', payload: { threadHashes: threadHashes1, }, }; const clearOp: RemoveAllIntegrityThreadHashesOperation = { type: 'remove_all_integrity_thread_hashes', }; const replaceOp2: ReplaceIntegrityThreadHashesOperation = { type: 'replace_integrity_thread_hashes', payload: { threadHashes: threadHashes2, }, }; const replaceOp3: ReplaceIntegrityThreadHashesOperation = { type: 'replace_integrity_thread_hashes', payload: { threadHashes: threadHashes3, }, }; const dbOperations: $ReadOnlyArray<ClientDBIntegrityStoreOperation> = integrityStoreOpsHandlers.convertOpsToClientDBOps([ clearOp, replaceOp1, clearOp, replaceOp2, replaceOp3, ]); try { await commCoreModule.processIntegrityStoreOperations(dbOperations); console.log('migration 64 succeeded'); } catch (exception) { console.log('migration 64 failed'); if (isTaskCancelledError(exception)) { return state; } return handleReduxMigrationFailure(state); } return state; },
Successfully wrote test thread hashes to the sqlite database:
Tested web with these steps:
- Log out, clear the app data, log in
- Run the app from before the store is introduced to the DB. Close the app, serve a new version, and open the app.
- Close the app while hashes are being computed (in the old version). Close the app, serve a new version, and open the app.
Used Kamil's diff for downloading database on web to check database contents are correct and reflect latest thread changes
Depends on D11309
Reviewers: kamil, tomek, atul
Reviewed By: tomek
Subscribers: ashoat
Differential Revision: https://phab.comm.dev/D11349