Implementing Migration Patterns

1. Strangler Fig Pattern

StepDetail
FaçadeRouting layer in front of legacy
ExtractMove one capability at a time to new service
RouteFaçade routes that capability to new service
RepeatUntil legacy is empty
DecommissionRemove legacy when traffic = 0

Strangler Fig Flow

Client ─▶ Façade ─┬─▶ Legacy (shrinking)
                  └─▶ NewSvcA, NewSvcB, ... (growing)
        

2. Anti-Corruption Layer Pattern

AspectDetail
PurposeTranslation layer between new service domain and legacy model
BenefitNew service stays clean; legacy quirks isolated
ImplementationAdapter / façade with mapping logic

3. Branch by Abstraction Pattern

StepDetail
1. AbstractIntroduce interface over existing implementation
2. Migrate CallersAll callers go through abstraction
3. Add New ImplImplement new behavior behind same abstraction
4. SwitchToggle to new impl gradually
5. Remove OldDelete old impl when stable

4. Parallel Run Pattern

AspectDetail
MechanismRun old + new; compare outputs; alert on diffs
Source of TruthOld, until confidence achieved
ToolsGitHub Scientist, custom diff loggers

5. Feature Toggle Migration Pattern

AspectDetail
MechanismToggle controls old vs new path; per-tenant or %
BenefitInstant rollback; gradual rollout
CleanupRemove toggle after full migration

6. Incremental Migration Pattern

PrincipleDetail
Small StepsMany small migrations vs one big-bang
Always ReleasableSystem works after every step
ReversibleEach step rollback-able
MeasuredMigration progress tracked (e.g., % moved)

7. Dual Write Pattern

AspectDetail
MechanismWrite to both old + new stores during migration
RisksInconsistency on partial failure
Better AlternativeCDC from old → new (single source of write)
VerificationReconciliation jobs compare both stores
Warning: Dual write is dangerous — without 2PC, partial failures cause divergence. Prefer CDC or transactional outbox.

8. Facade Pattern

AspectDetail
PurposeSimplified interface over complex legacy
UseNew clients integrate with façade, not legacy directly
BenefitDecouples consumers from migration churn

9. Legacy Wrapper Pattern

AspectDetail
MechanismWrap legacy as a "service" with REST/gRPC API
BenefitTreat legacy as a microservice; defer rewrite
Watch ForWrapping ≠ refactoring; tech debt remains

10. Database Schema Evolution Pattern

Step (Expand & Contract)Detail
1. ExpandAdd new column / table; keep old
2. BackfillMigrate data old → new
3. Dual WriteApp writes both; reads still old
4. Switch ReadsRead from new; verify
5. Stop Old WritesApp writes new only
6. ContractDrop old column / table
ToolsFlyway, Liquibase, gh-ost (online)