Skip to content

[formulus] Remove legacy id-mapping support #546

@r0ssing

Description

@r0ssing

Component

  • formulus (React Native mobile app)
  • formulus-formplayer (React web app)
  • synkronus (Go backend server)
  • synkronus-cli (Command-line utility)
  • Documentation
  • Other (please specify)

Feature Description

Remove pre-release legacy support for server ingested/wrong row ids...

See instructions below:

Remove legacy observation row-id support (pre–go-live)

Older builds could have Watermelon idobservation_id after pull. The app now aligns them on ingest and keeps dual lookup / merge-by-column for those rows. Before go-live, drop that if you have no production DBs with mixed ids (or after a one-off cleanup).

Preconditions

  • Confirm no release channel has users on builds that created “split” rows, or
  • Run a one-time local DB migration (dev script / versioned migration): for each observations row where id != observation_id, either delete test data or rewrite id to match observation_id per Watermelon rules (see their docs on changing primary keys—often safer to export/re-import or clear pre-release installs).

Code to simplify/remove

  1. WatermelonDBRepo.findObservationRecord
    Remove the method. updateObservation, deleteObservation, and optionally getObservation / markObservationAsSynced should use observationsCollection.find(stableId) only (or keep getObservation’s existing try/find + query only if you still want lookup-by-column for debugging).

  2. markObservationsAsSynced
    Revert to a single query: Q.where('id', Q.oneOf(ids)) (ids from sync are domain observationId, which must equal row id).

  3. ObservationMapper.observationIdFromDBModel
    Either delete and use model.observationId everywhere (assert non-empty in dev), or keep model.observationId || model.id as a tight fallback with a console.warn if !model.observationId.

  4. Tests

    • ObservationMapper.syncIdentity.test.ts can keep asserting observationId column wins when it differs from id only if you still support fat rows in tests; otherwise simplify to id === observationId.
    • Remove any test copy that describes “legacy ingested rows.”
  5. Comments
    Search the repo for legacy, observation_id column, findObservationRecord, and clean up.

Quick verification after removal

  • npm test
  • Manual: create observation → sync → second device pull → edit → push; list/detail show one observation_id, no duplicate server rows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestvNextMinor"vNextMinor" would currently mean for example v1.1.0

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions