Markdown Editor

Migration Plan Template

System or data migration: strategy, phases, data mapping, reconciliation, cutover runbook, rollback, decommissioning

Perangkat Lunak & RekayasaLengkapmigrationplanmath

Cara menggunakan: Use it before moving a system, database or user population to a new platform. Fill scope, current and target state and the strategy first, then agree rollback triggers with numbers before writing the runbook. The main pitfall is reconciliation without thresholds, so a migration looks done while data is missing.

Pratinjau

Migration Plan: [System or data set] from [Source] to [Target]

Migration plan for moving a system, a data set or a user population from a source platform to a target platform without losing data, availability or trust. It covers scope, current and target state, strategy (big bang, phased, dual-write/dual-read, strangler), phases, data mapping, validation and reconciliation, the cutover runbook, rollback, communication, risks, success criteria and decommissioning. It is based on common industry practice for system and data migrations. Replace every [bracketed] value and every row marked Example.

Document control

FieldValue
Document ID[MIG-PROJECT-001]
Migration name[Orders database move from self-managed PostgreSQL 12 to managed PostgreSQL 16]
Migration type[System / Data / Platform / Tenant or user population]
Version[0.1]
Status[Draft / In review / Approved / In flight / Completed / Rolled back]
Migration owner[@name]
Technical lead[@name]
Planned windowYYYY-MM-DD to YYYY-MM-DD
Cutover dateYYYY-MM-DD HH:MM UTC
Classification[Internal / Confidential]
Related documents[ADR-0042, SDD-ORDERS-003, RUNBOOK-DB-07]

Approvals

RoleNameDecisionDate
Migration owner[@name][Approved]YYYY-MM-DD
Engineering lead (source system)[@name][Approved]YYYY-MM-DD
Engineering lead (target system)[@name][Approved]YYYY-MM-DD
Data owner[@name][Approved / Approved with conditions]YYYY-MM-DD
Security or privacy reviewer[@name][Approved]YYYY-MM-DD
Change advisory or release manager[@name][Approved for window]YYYY-MM-DD

Revision history

VersionDateAuthorChange summary
0.1YYYY-MM-DD[@name]First draft for strategy review
0.2YYYY-MM-DD[@name]Example: Switched from big bang to dual-write after load test showed a 9 hour backfill
1.0YYYY-MM-DD[@name]Approved for cutover

Contents

1. Scope and objectives

This section defines what is migrated, why, and what is explicitly left out.

1.1 Purpose

Example: Move the orders service and its 1.8 TB PostgreSQL 12 database from self-managed virtual machines to a managed PostgreSQL 16 service, so that the team stops running end-of-life database software and gains automated backups, point-in-time recovery and minor-version patching.

1.2 In scope

IDItemNotes
SC-01Example: orders database, 41 tables, 1.8 TBIncluding history tables from 2019
SC-02Example: orders-api and orders-worker servicesConnection strings and pool settings
SC-03Example: Nightly export job to the data warehouseRe-pointed to the new read replica
SC-04[Item][Notes]

1.3 Out of scope

ItemReasonOwner of follow-up
Example: audit_log archive older than 7 yearsRetention policy allows deletion; deleted before migration[@data-owner]
Example: Schema redesign of order_itemsSeparate project; migration is like-for-like[@tech-lead]
[Item][Reason][@name]

1.4 Objectives and constraints

  • Objectives: [no data loss; downtime below 15 minutes; no change to public API behaviour].
  • Constraints: [cutover outside peak trading hours; freeze on unrelated releases during the window; budget cap of the dual-run period].
  • Assumptions: [target environment provisioned and security-approved by YYYY-MM-DD; source write volume stays below 1,200 writes per second].

2. Current state

This section records the source system and every dependency that touches it.

AspectCurrent state
PlatformExample: PostgreSQL 12.17 on 2 VMs (primary plus streaming replica)
Data volumeExample: 1.8 TB, largest table order_events 1.1 TB, 2.3 billion rows
Write rateExample: peak 950 writes/s, average 310 writes/s
ConsumersExample: orders-api, orders-worker, BI export, finance reconciliation script
IntegrationsExample: logical replication slot read by CDC pipeline
Known issuesExample: 3 tables without primary keys; mixed timestamp and timestamptz

2.1 Dependency inventory

List every reader and writer. Discover them from connection logs, not from memory.

ConsumerAccessFrequencyOwnerMigration action
Example: orders-apiRead/writeContinuous[@team-orders]Switch connection string via config flag
Example: finance-recon.py on host fin-01Read onlyDaily 01:00[@finance-eng]Re-point and test in staging
[Consumer][Access][Frequency][@owner][Action]

3. Target state

This section describes where the system will be when the migration is complete.

AspectTarget stateDifference from current
PlatformExample: Managed PostgreSQL 16, multi-AZMajor version upgrade; managed failover
Data volumeExample: 1.5 TB after purge of expired archive0.3 TB deleted under retention policy
Consumers[Same list, new endpoints][Connection pooling via proxy]
Backup and recoveryExample: PITR 14 days, RPO 5 min, RTO 1 hPreviously nightly dumps only
SecurityExample: TLS required, IAM authenticationPreviously password authentication

The following diagram shows the target topology and the temporary migration path used during the dual-run period.

4. Migration strategy

This section records the chosen pattern and why the others were rejected.

4.1 Strategy options

StrategyHow it worksDowntimeComplexityBest when
Big bangStop writes, copy everything, switch all consumers at onceHours, proportional to data sizeLowSmall data, tolerant users, simple rollback
PhasedMove tenants, regions or modules in wavesMinutes per waveMediumData partitions cleanly by tenant or region
Dual-write / dual-readApplication writes to both systems, reads shift gradually after comparisonNear zeroHighZero-downtime requirement, application under team control
StranglerNew system takes over functions one route at a time behind a facadeNear zeroHigh, spread over monthsReplacing a legacy application, not just its storage
Replication-basedDatabase-native or CDC replication, then short write freeze and switchMinutesMediumLike-for-like storage moves

4.2 Chosen strategy and rationale

Example: Replication-based with a short write freeze, combined with phased consumer switching for read-only consumers. Logical replication keeps the target within seconds of the source; read-only consumers move first, then a 10 minute write freeze switches the writers. Big bang was rejected because a full copy takes about 9 hours at the measured throughput. Dual-write was rejected because it requires changes to two services and introduces consistency risk with no benefit for a like-for-like move.

4.3 Consequences

  • [Downtime budget: 10 minute write freeze; reads available throughout].
  • [Temporary cost: both databases run for up to 30 days].
  • [Operational load: replication lag must be monitored and alerted during the dual-run period].

5. Phases and schedule

The migration runs in the following phases. A phase starts only when the previous one has met its exit criteria.

PhaseGoalEntry criteriaExit criteriaOwner
P0 PreparationTarget provisioned, tooling readyPlan approvedTarget passes security review and load test[@platform]
P1 RehearsalFull dry run in stagingP0 exitRehearsal completed within window, reconciliation 100%[@tech-lead]
P2 Initial load and syncCopy data, start replicationP1 exitLag below 5 s for 72 h[@dba]
P3 Read consumers switchMove read-only consumersP2 exitConsumers healthy for 7 days[@team-leads]
P4 CutoverMove writersGo decision at T-1 hSuccess criteria in section 12 met[@migration-owner]
P5 HypercareWatch, fix, stabiliseP4 exit14 days without Sev 1 or Sev 2 related to migration[@on-call]
P6 DecommissionRemove sourceP5 exitSource deleted, costs stopped[@platform]

The schedule below is indicative; adjust the dates and durations.

6. Data mapping and transformation

This section maps source structures to target structures and records every transformation rule.

6.1 Field mapping

Map IDSource table.fieldTarget table.fieldType changeTransformation ruleInvalid value handling
DM-001Example: orders.created_at (timestamp)orders.created_at (timestamptz)YesInterpret as UTCReject row, log to quarantine
DM-002Example: orders.status (varchar)orders.status (enum)YesMap 'cancelled' and 'canceled' to canceledUnknown value goes to quarantine
DM-003Example: customers.phonecustomers.phone_e164FormatNormalise to E.164Keep original in phone_raw
DM-004[Source][Target][Yes/No][Rule][Handling]

6.2 Data quality and cleansing

  • [Known defects found by profiling and how each is handled: fixed at source, transformed, quarantined or accepted].
  • [Rows without primary keys: surrogate key added before replication].
  • [Personal data: confirm lawful basis and retention before copying; do not copy data that is due for deletion].

6.3 Quarantine

Rows that fail transformation go to a quarantine table with the source key, the failing rule and a timestamp. The data owner reviews quarantine daily during the migration; the target is zero unresolved rows at cutover.

7. Validation and reconciliation

Reconciliation proves that the target holds the same data as the source, after transformation. Each check below has a threshold and an owner.

7.1 Metrics

The row-count match rate for a table tt compares target and source counts after excluding rows that were deliberately quarantined or filtered:

Rrows(t)=Ntarget(t)Nsource(t)−Nexcluded(t)R_{\text{rows}}(t) = \frac{N_{\text{target}}(t)}{N_{\text{source}}(t) - N_{\text{excluded}}(t)}

The checksum match rate compares per-row hashes over the mapped columns, computed on both sides with the same canonical serialisation:

Rchecksum(t)=∣{ k:hsrc(k)=htgt(k) }∣Ncompared(t)R_{\text{checksum}}(t) = \frac{\left|\{\,k : h_{\text{src}}(k) = h_{\text{tgt}}(k)\,\}\right|}{N_{\text{compared}}(t)}

For very large tables, compare a random sample of nn rows. With n=10,000n = 10{,}000 and zero mismatches, the 95% upper bound on the mismatch rate is about 3/n=0.03%3/n = 0.03\% (the rule of three).

7.2 Checks and thresholds

Check IDCheckScopeThresholdWhenOwner
VR-01Row count match RrowsR_{\text{rows}}All tables=1.0= 1.0 exactlyRehearsal, T-1 h, T+15 min[@dba]
VR-02Checksum match RchecksumR_{\text{checksum}}Tables under 50 M rows=1.0= 1.0Rehearsal, T+30 min[@dba]
VR-03Sampled checksumTables over 50 M rows0 mismatches in 10,000 rowsT+30 min[@dba]
VR-04Aggregate totalsExample: sum of order_total per dayEqual to the centT+30 min[@finance-eng]
VR-05Replication lagSource to targetBelow 5 s before freeze, 0 at switchContinuous[@on-call]
VR-06Application smoke testsCritical journeys100% passT+10 min[@qa]

7.3 Mismatch handling

A failed check is investigated before the next runbook step. If the cause cannot be found within [30 minutes], the go/no-go owner applies the rollback triggers in section 9.

8. Cutover runbook

The runbook below is executed in a bridge call with the migration owner as coordinator. Each step is checked off in the log in Appendix B.

StepTimeActionCommand or linkExpected resultOwner
1T-24 hConfirm go/no-go prerequisitesChecklist in 8.1All items green[@migration-owner]
2T-1 hFinal go/no-go decisionBridge callRecorded decision[@migration-owner]
3T-30 minPost "maintenance starting" noticeStatus page templateNotice live[@comms-lead]
4T-10 minEnable write freeze[feature flag orders.write_freeze=on]Write rate drops to 0[@tech-lead]
5T-8 minConfirm replication lag is 0[lag query]Lag 0 bytes[@dba]
6T-5 minRun VR-01 on all tables[reconcile --counts]All match[@dba]
7T-2 minAdvance sequences on target[script]Sequences above source max[@dba]
8TSwitch connection target[config change orders.db=target]Services connect to target[@tech-lead]
9T+2 minDisable write freeze[flag off]Writes succeed on target[@tech-lead]
10T+10 minSmoke tests VR-06[test command]100% pass[@qa]
11T+30 minChecksums VR-02 to VR-04[reconcile --checksums]Thresholds met[@dba]
12T+60 minDeclare cutover complete or roll backBridge callDecision recorded[@migration-owner]

8.1 Go/no-go checklist

  • Rehearsal completed within the planned window with full reconciliation.
  • Replication lag below threshold for the last 72 hours.
  • Rollback procedure rehearsed and reverse replication ready.
  • On-call and decision makers confirmed on the bridge.
  • Communications drafted and approved.
  • No open Sev 1 or Sev 2 incidents on dependent systems.

9. Rollback

This section defines when and how the migration is reversed.

9.1 Rollback triggers

Trigger IDConditionMeasured byDecision owner
RB-01Error rate above 2% for 5 minutes after switchAPI dashboards[@migration-owner]
RB-02Any reconciliation check VR-01 to VR-04 fails and is not explained within 30 minutesReconciliation report[@migration-owner]
RB-03p99 latency above 2x baseline for 15 minutesAPM[@migration-owner]
RB-04Data corruption observed by any consumerIncident report[@migration-owner]

9.2 Rollback procedure

  1. Enable the write freeze.
  2. Confirm reverse replication (target to source) has applied all writes made since T; otherwise export them from the target change log.
  3. Switch the connection target back to the source.
  4. Disable the write freeze and run smoke tests.
  5. Post the rollback notice and open an incident record.

9.3 Point of no return

Example: Reverse replication is kept for 7 days after cutover. After the source is set read-only and reverse replication stops (start of P6), rollback is no longer possible and issues are fixed forward.

10. Communication plan

Communication is owned by the comms lead and approved by the migration owner.

AudienceMessageWhenChannelOwner
Engineering teams consuming the dataPlan, freeze window, consumer actionsT-14 days, T-2 days[Engineering channel, email][@migration-owner]
Support and customer successExpected impact, customer wordingT-7 days[Briefing][@comms-lead]
CustomersMaintenance noticeT-72 h and T-30 minStatus page[@comms-lead]
ExecutivesGo/no-go outcome, completionT-1 h, T+60 min[Email][@migration-owner]
AllCompletion or rollback noticeT+60 minStatus page and channel[@comms-lead]

11. Risks and mitigations

Risk score is likelihood times impact, each on a 1 to 5 scale, so S=L×IS = L \times I ranges from 1 to 25; scores of 12 or more need a mitigation tested in rehearsal.

Risk IDRiskLIScoreMitigationOwner
MR-01Example: Hidden consumer still writes to the source after cutover3515Revoke write grants on source at T; monitor source connections[@dba]
MR-02Example: Query plans regress on new major version3412Replay production queries in rehearsal; compare plans[@tech-lead]
MR-03Example: Sequence collision after switch2510Step 7 advances sequences with a safety gap[@dba]
MR-04Example: Cutover overruns the window236Rehearsed timings; hard stop at T+90 min triggers rollback[@migration-owner]
MR-05[Risk][L][I][S][Mitigation][@owner]

12. Success criteria

The migration is complete when all of the following hold:

IDCriterionTargetEvidence
SUC-01Data completenessVR-01 to VR-04 passReconciliation report
SUC-02DowntimeWrite freeze at most 15 minutesRunbook log timestamps
SUC-03Performancep99 latency within 10% of baseline for 7 daysAPM dashboard
SUC-04StabilityNo migration-related Sev 1 or Sev 2 during hypercareIncident log
SUC-05ConsumersEvery consumer in 2.1 confirmed on targetSign-off list

13. Decommissioning

Decommissioning removes the source once success criteria are met and the point of no return has passed.

StepActionVerificationOwner
D-01Set source read-only and stop reverse replicationWrite attempts rejected[@dba]
D-02Take a final encrypted backup and store it per retention policyBackup restore test passes[@dba]
D-03Remove DNS entries, credentials, firewall rules and monitoringNo residual access[@platform]
D-04Delete source instances and storageBilling shows zero cost[@platform]
D-05Update runbooks, architecture docs and the dependency inventoryDocs reviewed[@tech-lead]
D-06Hold a retrospective and record lessonsRetro notes linked[@migration-owner]

14. Appendices

Appendix A. Glossary

TermMeaning
CutoverThe moment writers switch from source to target
Write freezeA period in which the application rejects or queues writes
ReconciliationComparing source and target to prove completeness and correctness
HypercareThe period of heightened monitoring after cutover

Appendix B. Cutover log

Time (UTC)StepResultByNotes
HH:MM[Step number][Done / Failed / Skipped][@name][Notes]

Appendix C. Rehearsal results

RehearsalDateDurationReconciliationIssues found
Example: R1 stagingYYYY-MM-DD52 min100%Sequence step missing; added as step 7

Standard and licence note

Based on common industry practice for system and data migrations (replication-based moves, phased waves, dual-write and the strangler pattern), with reconciliation and rollback practices commonly used in database and platform engineering. No named standard is reproduced. Template licence: MIT.

Templat terkait