professional work

Lead Assignment Architecture Migration

Migrated lead ownership from a single column to a join table under live production traffic.

Full-Stack Developer · Undisclosed · Oct 2025 — Present


context

Lead ownership was stored as a single column on the leads table. That made it impossible to assign a lead to more than one agent. I needed to migrate to a normalized join table without taking the system down.


the challenge

If I missed any write point during the migration, the old column and the new table would silently go out of sync. The system would appear to work but serve stale data from some paths and fresh data from others.


approach

  • 1.I used a dual-write approach. The new join table became the source of truth, but every write path also continued writing to the old column at the same time. That kept both in sync during the transition.
  • 2.I audited 15+ write-point locations across the codebase: KPI stats, permission checks, automation rules, integration routers, bulk operations, team performance queries, cascade deletes. Each one needed to write to both destinations.
  • 3.I migrated read paths one at a time instead of switching everything at once. Each step was verifiable before I moved to the next.

technical highlights

  • 15+ write points updated across the codebase, each verified independently.
  • I extracted shared assignment helpers to consolidate the write paths and reduce the chance of future drift between them.
  • No downtime. The dual-write window kept both representations in sync the whole way through.

result

Migration finished under live traffic. No data loss, no downtime, and multi-assign is now possible.


technologies

Backend ArchitecturePostgreSQLDual-Write PatternProduction Safety

Some implementation details have been generalized to respect employer confidentiality.