Skip to content

Normalize existing phone numbers to E.164 format #23

Closed

Description

@khaira777

Summary

Normalize existing phone numbers in the database to E.164 format and backfill country_id on customers.

Part of epic: #18
Blocked by: #19 (Phase 1 — phone input fix)

Scope

  • Migration script to convert all phone numbers to E.164
  • Backfill country_id on customers based on phone dial code
  • Handle edge cases (numbers without country code, invalid formats)

Files Touched

  • New: scripts/normalize-phones.ts (migration script)
  • main/db.ts (migration)

Acceptance Criteria

  • All phone numbers in the database are in E.164 format (start with +)
  • All customers have a country_id (or null for unparseable numbers)
  • Edge cases are handled gracefully (numbers without country code → default to tenant country)
  • No data loss during migration
  • Migration is idempotent (safe to run multiple times)

Notes

  • This is a data migration, not a feature — it cleans up existing data
  • Numbers that can't be parsed are left as-is and flagged for manual review
  • The migration should be run after Phase 1 ships (new numbers are already E.164)
  • Consider adding a phone_normalized boolean column to track migration status

Activity

  1. added
    enhancement
    on Jul 6, 2026
  2. khaira777 commented on Jul 6, 2026

    @khaira777
    ContributorAuthor

    Part of epic #18 — Internationalization

  3. added theissue type on Jul 6, 2026
  4. khaira777 commented on Jul 18, 2026

    @khaira777
    ContributorAuthor

    ✅ Completed in PR #119.

    • Migration v22: phone_digits VIRTUAL generated column
    • Migration v23: normalize_customer_phones — parses all phones to E.164 using tenant country, merges duplicate customers, creates unique index on phone_digits
    • Migration v24: retry pass for phones v23 missed
    • Test coverage: tests/phone-migration.test.ts
    • Commit: 60bdf17, 166e651

    Closing as complete.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions