All problems

User Mapping Error in Notification Settings Migration

Level 3 · node · Data · Migration error

Scenario

A one-time migration moves each user’s legacy emailEnabled setting into a new preferences store during a notification-settings schema change. The row count is correct and the migration finishes without errors, but some users receive another user’s setting. The legacy repository and user repository may return rows in different orders, and the migration, mapper, and repositories are separated.

Requirements

- Each user must receive the legacy emailEnabled value belonging to the same userId - Results must remain correct when user and legacy repositories return rows in different orders - A current user with no legacy setting gets the default value false - A legacy row for a nonexistent user must not create a new preference - After migration, each current user has exactly one preference row

Acceptance criteria

  • Each user keeps their own legacy emailEnabled value even when query orders differ
  • A user with no legacy setting is created with emailEnabled false
  • Legacy settings for users not in the current user list are excluded
  • The migration result contains exactly one preference row for each current user
  • Running the migration again does not create duplicate preference rows for the same userId