Page MenuHomePhabricator

[lib] Fix SQLite migrations
ClosedPublic

Authored by tomek on Wed, Oct 2, 5:04 AM.
Tags
None
Referenced Files
F2873041: D13571.diff
Wed, Oct 2, 11:21 PM
F2869777: D13571.id44827.diff
Wed, Oct 2, 5:41 PM
F2868449: D13571.id44827.diff
Wed, Oct 2, 3:10 PM
F2867465: D13571.id44821.diff
Wed, Oct 2, 1:51 PM
F2866815: D13571.id.diff
Wed, Oct 2, 12:03 PM
F2864780: D13571.diff
Wed, Oct 2, 6:54 AM
F2864619: D13571.diff
Wed, Oct 2, 6:34 AM
F2864285: D13571.id44821.diff
Wed, Oct 2, 6:02 AM
Subscribers
None

Details

Summary

The migrations are broken because we weren't using the right shape of the specification. This diff fixes it and introduces necessary type checks.

https://linear.app/comm/issue/ENG-9467/redux-migrations-are-broken

Test Plan

Tested this by creating a new migration on the web where a new draft is created. Run the app, and reopened it. Checked if the SET_CLIENT_DB_STORE action contains the draft.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

native/redux/persist.js
1371 ↗(On Diff #44820)

Even adding this check doesn't force Flow to verify the migrations' types so we have to explicitly annotate each migration.

tomek requested review of this revision.Wed, Oct 2, 5:25 AM
ashoat added inline comments.
lib/utils/migration-utils.js
207 ↗(On Diff #44821)

I would name this MigrationFunction

210 ↗(On Diff #44821)

Why remove PersistedState here?

This revision is now accepted and ready to land.Wed, Oct 2, 5:31 AM
lib/utils/migration-utils.js
210 ↗(On Diff #44821)

PersistedState is an optional AppState. We were telling here that it can be used as an argument, but our migration functions were assuming that the state is mandatory. This issue was discovered by making the migration types explicit.

This revision was automatically updated to reflect the committed changes.