Skip to content

fix(persistence): drop the cached transaction history on upgrade - #1284

Closed
bmc08gt wants to merge 1 commit into
code/cashfrom
claude/drop-transaction-history-upgrade-bfeea2
Closed

fix(persistence): drop the cached transaction history on upgrade#1284
bmc08gt wants to merge 1 commit into
code/cashfrom
claude/drop-transaction-history-upgrade-bfeea2

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Bumps the DB to v29 with a data-only auto migration that clears the messages table.

Why

The feed is a cache of the server's activity history, not a source of truth — FeedRemoteMediator clears and re-fetches it on every REFRESH, so an emptied table repopulates on the next load.

Rows written by older mappers, though, are never rewritten once the server stops sending that notification. Stale metadata, amounts, and substitutions render forever. Clearing on upgrade sheds them.

How

There's no schema change, so this rides the auto migration and does its work in onPostMigrate — the same shape as the existing Migration22To23. The generated 29.json is byte-identical to 28.json apart from the version (same identityHash), which is what makes the empty auto-migration valid.

It takes the onPostMigrate(SQLiteConnection) overload rather than the SupportSQLiteDatabase one: the latter only fires when Room is built without a driver, so a future .setDriver(...) would turn the delete into a silent no-op. (Migration22To23 has the same latent issue; left alone since it works as currently configured.)

Onboarding milestone

Clearing the table transiently resets hasEverReceivedMoney(), which drives the wallet's "added money" tutorial item. That's the same state as a fresh install, and ActivityFeedCoordinator.syncState already exists to distinguish "empty account" from "haven't fetched yet" — so a returning user doesn't get flashed new-user onboarding in the window before the first fetch lands.

Tests

TransactionHistoryMigrationTest follows the hand-rolled pattern in UserProfileMigrationTest: asserts the feed is emptied, that a neighbouring table (blocked_users) is untouched, and that it's a no-op on an already-empty feed.

Bumps the DB to v29 with a data-only auto migration that clears the
`messages` table.

The feed is a cache of the server's activity history, not a source of
truth: FeedRemoteMediator clears and re-fetches it on every REFRESH, so
an emptied table repopulates on the next load. Rows written by older
mappers, though, are never rewritten once the server stops sending that
notification — so stale metadata, amounts, and substitutions render
forever. Clearing on upgrade sheds them.

There is no schema change, so this rides the auto migration and does its
work in onPostMigrate (same shape as Migration22To23). It takes the
SQLiteConnection overload rather than the SupportSQLiteDatabase one:
the latter only fires when Room is built without a driver, so a future
setDriver would turn the delete into a silent no-op.

The wallet already distinguishes "no activity" from "haven't looked yet"
via ActivityFeedCoordinator.syncState, so the empty window before the
first fetch doesn't flash new-user onboarding at an established user.
@github-actions github-actions Bot added the type: fix Bug fix label Aug 20, 2026
bmc08gt added a commit that referenced this pull request Aug 20, 2026
Folds in the standalone migration work from #1284, which duplicated the
28 -> 29 clear this branch already carries.

Adds TransactionHistoryMigrationTest, following the hand-rolled pattern
in UserProfileMigrationTest: asserts the feed is emptied, that a
neighbouring table survives, and that it's a no-op on an already-empty
feed.

Also switches Migration28To29 to the onPostMigrate(SQLiteConnection)
overload. Room's SupportSQLiteDatabase variant only fires when the
database is built without a driver, so a future setDriver would turn the
delete into a silent no-op.
@bmc08gt

bmc08gt commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #1281, which already carried the same 28 → 29 messages clear. The migration test and the driver-safe onPostMigrate(SQLiteConnection) overload from this branch have been folded into #1281 (bcf574c). Closing in favour of that PR.

@bmc08gt bmc08gt closed this Aug 20, 2026
bmc08gt added a commit that referenced this pull request Aug 20, 2026
* fix(activity): show Convert transactions in the feed

A swap spans two mints, so the backend leaves `payment_amount` unset and carries
both amounts in `additional_metadata` instead. `ActivityFeedMessageMapper` only
ever read `payment_amount`, so every Convert cached with a null amount, rate, and
mint — which meant it matched no token's activity query and rendered blank in the
global feed.

- Map multi-mint amounts from `additional_metadata` when `payment_amount` is absent.
- Attribute a Convert to *both* mints, so it appears on the source and destination
  token screens (`MintInvolvement` + the metadata clause in `observeRecentForMint`).
- Render it the way iOS does: overlapping dual-token avatar, from-amount on top,
  `-<fee> Fee` beneath.
- Title the row with the two token names ("Moony -> Jeffy") rather than the
  server's bare "Converted", falling back to the server text until both tokens
  resolve.

Rows cached before this can't be repaired in place (the amounts were never
persisted) and can't be re-fetched either, since sync only walks forward from the
newest cached id. DB 28 -> 29 clears `messages` so the next sync re-seeds from
scratch — the same approach as the existing 1->2, 6->7, 7->8 and 9->10 migrations.

Also fixes a silent data-loss path found alongside it: `MessageDataSource.upsert`
no-oped when the per-user DB wasn't open yet, discarding a whole fetched page
while the coordinator still reported `Synced`. Because every sync path pages
forward from the newest cached id, those notifications were never requested
again. It now fails loudly (matching `observe()`, which already errors on a
missing DB), the mediator turns that into a retryable error, and the coordinator
only reports `Synced` once the write has actually landed.

* test(persistence): cover the v29 feed-clearing migration

Folds in the standalone migration work from #1284, which duplicated the
28 -> 29 clear this branch already carries.

Adds TransactionHistoryMigrationTest, following the hand-rolled pattern
in UserProfileMigrationTest: asserts the feed is emptied, that a
neighbouring table survives, and that it's a no-op on an already-empty
feed.

Also switches Migration28To29 to the onPostMigrate(SQLiteConnection)
overload. Room's SupportSQLiteDatabase variant only fires when the
database is built without a driver, so a future setDriver would turn the
delete into a silent no-op.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant