HomePhabricator
Diffusion Comm d93872ce1f66

[native] migrate integrityStore to SQLite

Description

[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:

Screenshot 2024-03-18 at 7.37.48 PM.png (288×332 px, 49 KB)

Tested web with these steps:

  1. Log out, clear the app data, log in
  2. Run the app from before the store is introduced to the DB. Close the app, serve a new version, and open the app.
  3. 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

Details

Provenance
willAuthored on Mar 13 2024, 10:45 AM
Reviewer
tomek
Differential Revision
D11349: [native] migrate integrityStore to SQLite
Parents
rCOMMd27ead6e8d4c: [sqlite] implement processing integrity store ops on worker
Branches
Unknown
Tags
Unknown