Page MenuHomePhabricator

[lib] Fix SQLite migrations
ClosedPublic

Authored by tomek on Oct 2 2024, 5:04 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 16, 2:24 PM
Unknown Object (File)
Mon, Dec 16, 2:24 PM
Unknown Object (File)
Mon, Dec 16, 2:24 PM
Unknown Object (File)
Mon, Dec 16, 2:24 PM
Unknown Object (File)
Wed, Nov 27, 8:02 AM
Unknown Object (File)
Sat, Nov 23, 3:54 PM
Unknown Object (File)
Sat, Nov 23, 1:06 PM
Unknown Object (File)
Fri, Nov 22, 4:32 PM
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
Branch
master
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

native/redux/persist.js
1371

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.Oct 2 2024, 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.Oct 2 2024, 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.