Skip to content

[MS-1501] implement db migration backfilling empty referenceIds#1738

Open
meladRaouf wants to merge 1 commit into
mainfrom
bugfix/empty-reference-id
Open

[MS-1501] implement db migration backfilling empty referenceIds#1738
meladRaouf wants to merge 1 commit into
mainfrom
bugfix/empty-reference-id

Conversation

@meladRaouf

@meladRaouf meladRaouf commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

MS-1501

Will be released in: v2026.3.0

Root cause analysis (for bugfixes only)

First known affected version: v2025.1.0

  • referenceId was added to face/fingerprint samples in v2025.1.0 , but no migration backfilled it for existing samples — Realm defaulted it to "".
  • This empty value carried through the Realm→Room migration into DbBiometricTemplate, leaving subjects enrolled before v2025.1.0 with a permanently empty referenceId after upgrade.

Notable changes

  • RealmMigrations (schema → v19): backfills a shared UUID per subject+modality for samples with empty referenceId.
  • SubjectMigration2to3 (Room DB → v3): same backfill applied to DbBiometricTemplate rows.
  • Existing valid referenceIds are left untouched.

Testing guidance

  1. Enrol subjects on v2024.2.2, upgrade to this build, and confirm SELECT * FROM DbBiometricTemplate WHERE referenceId='' returns no rows.
  2. Run Migration2to3Test and RealmMigrationsTest.
  3. I have created a testiny test so we can cover it in release testing https://app.testiny.io/SID/testcases/tcf/41/tc/321/

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements data migrations to backfill previously-empty referenceId values for biometric samples/templates so that legacy enrolments (created before referenceId existed) receive stable, non-empty IDs grouped per subject + modality across both Realm and Room storage.

Changes:

  • Add Room DB migration 2 -> 3 to backfill empty DbBiometricTemplate.referenceId per (subjectId, modality) and bump SubjectsDatabase version to 3.
  • Add instrumentation migration test to verify Room backfill behavior and preservation of existing referenceIds.
  • Add Realm schema migration 18 -> 19 to backfill empty sample referenceIds per modality and bump Realm schema version to 19 (with a unit test).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
infra/enrolment-records/room-store/src/test/java/com/simprints/infra/enrolment/records/room/store/migration/Migration2to3Test.kt Adds instrumentation coverage for the Room 2→3 backfill migration.
infra/enrolment-records/room-store/src/main/java/com/simprints/infra/enrolment/records/room/store/SubjectsDatabase.kt Registers the new Room migration and bumps DB version to 3.
infra/enrolment-records/room-store/src/main/java/com/simprints/infra/enrolment/records/room/store/migration/SubjectMigration2to3.kt Implements Room 2→3 backfill of empty referenceId per (subjectId, modality).
infra/enrolment-records/room-store/schemas/com.simprints.infra.enrolment.records.room.store.SubjectsDatabase/3.json Adds exported Room schema snapshot for v3.
infra/enrolment-records/realm-store/src/test/java/com/simprints/infra/enrolment/records/realm/store/migration/RealmMigrationsTest.kt Adds test coverage for Realm 18→19 referenceId backfill behavior.
infra/enrolment-records/realm-store/src/main/java/com/simprints/infra/enrolment/records/realm/store/migration/RealmMigrations.kt Implements Realm 18→19 backfill of empty sample referenceIds per modality.
infra/enrolment-records/realm-store/src/main/java/com/simprints/infra/enrolment/records/realm/store/config/RealmConfig.kt Bumps Realm schema version to 19 to activate the new migration.

@meladRaouf meladRaouf force-pushed the bugfix/empty-reference-id branch from c03c2be to 95f85ae Compare July 11, 2026 09:17
@meladRaouf meladRaouf force-pushed the bugfix/empty-reference-id branch from 95f85ae to fc71b41 Compare July 11, 2026 09:22
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants