SfSkills Domains Docs GitHub

Home / data / data-migration-planning

data-migration-planning

Use when planning, reviewing, or troubleshooting a Salesforce data migration — covering tool selection (Data Loader, Bulk API 2.0, MuleSoft, Informatica, Jitterbit), migration sequencing for parent-child objects, external ID strategy for upsert idempotency, validation rule bypass, trigger and flow suppression, rollback planning, and post-migration reconciliation. NOT for Data Loader step-by-step mechanics — use admin/data-import-and-management. NOT for schema or data model design — use data/data-model-design-patterns.

Open the skill folder on GitHub


Data Migration Planning

This skill activates when a practitioner needs to plan or review a Salesforce data migration: choosing the loading tool, sequencing objects by dependency, keying records by external ID, keeping automation and sharing from slowing or blocking the load, and having a rollback and reconciliation plan before the first row is written.


Before Starting

Gather this context before working on anything in this domain:

ContextWhat to confirm
Object inventory and volumesObjects, rows per object, lookup versus master-detail relationships
Source keysThe natural identifier per object; it becomes an External ID field
AutomationValidation rules, triggers, flows, and workflow rules on each target object
Owners and audit fieldsWhether owners are active users, and whether original CreatedDate and CreatedBy must be kept
Sharing modelWhether the load can run with Public Read/Write defaults and deferred sharing calculation
Volume limitsBulk API 2.0: 150,000,000 records per rolling 24 hours, internal batches of 10,000; Data Loader supports files up to 150,000,000 records with Bulk API 2.0

Questions to Ask Before Configuring

AskWhy it mattersWhat a good answer adds
"What is the source key for each object, and is it unique and stable?"Upserts and relationship columns in load files match on indexed fields such as External IDs; a key matched more than once fails the row (Gotcha 2)One External ID field per object, set Unique when the key must be unique
"Which validation rules, triggers, and flows will fire, and which must be skipped for the migration user only?"The LDV guide recommends disabling triggers, workflow rules, and validations during loads; doing it org-wide exposes other users (Gotcha 1)A bypass scoped to the migration user through a custom permission or user-level hierarchy setting
"Must original created dates, creators, and owners be kept?"Audit fields can only be set on create, with the Set Audit Fields upon Record Creation permission (Gotcha 3)The permission enabled for the migration user before the first insert
"Are any owners inactive users?"Records owned by inactive users need a decision before load (Gotcha 4)An owner map, with placeholders or the inactive-owner permission tested in a sandbox
"Which relationship columns reference parents, and through which parent field?"Bulk API relationship headers allow only one level and only indexed parent fields (Gotcha 5)Load files whose parent references resolve
"Can sharing recalculation wait until the data is in?"Ownership and sharing changes during the load add computation and lock contention (Gotcha 6)Defer sharing calculation, or Public Read/Write defaults during the initial load
"How will a bad batch be removed, and does deletion need to be permanent?"Deleted records stay in the Recycle Bin for 15 days unless hard deleted (Gotcha 7)A batch ID field and a reverse-order delete runbook

A planned migration adds keys, sequence, scoped bypasses, and a tested rollback; "just loading the files" produces duplicates on re-run, orphaned children, and automation side effects that are hard to undo.


Core Concepts

Tool selection

ToolUse whenNotes
Data LoaderAn operator runs object-by-object loads and wants success and error CSVsCan use SOAP API, Bulk API, or Bulk API 2.0; with Bulk API 2.0 batch sizes are handled automatically
Bulk API 2.0 (direct)Large or scripted loadsCSV only; 150 MB per job; results via successfulResults, failedResults, unprocessedrecords (see data/bulk-api-patterns)
ETL platform (MuleSoft, Informatica, Jitterbit)Heavy transformation, or the pipeline continues as an integration after cutoverAdds a mapping and retry layer

The LDV guide calls any operation over 2,000 records a candidate for Bulk API 2.0, and ranks operations by speed: insert, then update, then upsert. Where the source cleanly separates new and existing rows, an insert pass and an update pass are faster than one upsert; upsert stays the safe default for re-runnable loads.

Sequencing

Load owners and queues first, then parents before children: Accounts, Contacts, Opportunities, Products and Price Book Entries, Opportunity Line Items, Cases, Case Comments. Self-references (Contact ReportsTo) can use a relationship column to a record already loaded, or a second update pass after all rows exist.

External IDs and relationship columns

Mark each source key field External ID (Auto Number, Email, Number, or Text). That indexes it and makes it usable as the upsert key. A child file can then reference its parent by that key: Account.Legacy_Id__c for a standard lookup, Parent_Object__r.Legacy_Id__c for a custom one.

<?xml version="1.0" encoding="UTF-8"?>
<!-- excerpt: objects/Account/Account.object-meta.xml — External ID key plus a migration-user bypass
     on one validation rule. Merge into retrieved metadata; do not deploy this fragment as-is. -->
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
    <fields>
        <fullName>Legacy_Id__c</fullName>
        <label>Legacy ID</label>
        <type>Text</type>
        <length>40</length>
        <externalId>true</externalId>
        <unique>true</unique>
    </fields>
    <validationRules>
        <fullName>Billing_Country_Required</fullName>
        <active>true</active>
        <errorConditionFormula>AND(NOT($Permission.Bypass_Migration_Validation), ISBLANK(BillingCountry))</errorConditionFormula>
        <errorMessage>Billing Country is required.</errorMessage>
    </validationRules>
</CustomObject>

Automation and sharing during the load

ConcernApproach
Validation rulesAdd NOT($Permission.<Custom_Permission>) to each rule that must not block migration rows; grant the permission through a permission set to the migration user only
TriggersCheck a hierarchy custom setting with Migration_Control__c.getInstance().Skip_Automation__c and set the value at the migration user's level, or check the custom permission with FeatureManagement.checkPermission
FlowsAdd an entry condition or first Decision on the same custom permission
SharingDefer sharing calculation, or load with Public Read/Write defaults and tighten after
LockingGroup child rows by parent in the same batch

Rollback

Stamp every migrated row with Migration_Batch_Id__c. To roll back a batch, delete its rows child objects first, in reverse load order. Use Bulk API hard delete when the rows must not stay restorable in the Recycle Bin (the user needs the "Bulk API Hard Delete" permission).


  1. Fill templates/data-migration-planning-template.md: objects, volumes, keys, dependency order, automation inventory, owner map, audit-field decision, and rollback runbook.
  2. Write migration_sequence.csv (object,depends_on,bypass_documented) and put the load CSVs and target metadata (objects/) next to it.
  3. Run python3 skills/data/data-migration-planning/scripts/check_data_migration_planning.py --manifest-dir <migration folder> and fix every ERROR (sequence order, unindexed or grandparent relationship columns); review WARN lines (missing key columns, rules without a bypass).
  4. Deploy External ID fields, the bypass permission set, and the batch ID field to a full-copy sandbox; run each load with a sample of a few hundred rows, then the full volume.
  5. Reconcile counts, sample field values, and orphan checks per object (data/data-reconciliation-patterns); rehearse the rollback once.
  6. Repeat in production during the cutover window, following the runbook in references/cutover-worked-example.md (it also has a troubleshooting table); remove the bypass permission set and reset sharing settings immediately after.

Review Checklist


Salesforce-Specific Gotchas

Full write-ups are in references/gotchas.md:

#Gotcha
1Automation fires for the migration user unless the bypass is built in
2External ID indexes and matches but does not make values unique
3Original audit values can only be set on create, with a permission
4Inactive owners need a decision before the load
5Relationship columns allow one level and indexed parent fields only
6Sharing and locking slow large loads unless planned
7Rollback deletes leave rows restorable unless hard deleted
8Master-detail children fail without a parent value

Output Artifacts

ArtifactDescription
Migration planFilled templates/data-migration-planning-template.md
Sequence filemigration_sequence.csv checked by the skill's checker
Key and bypass metadataExternal ID fields, bypass custom permission, permission set, batch ID field
Rollback runbookReverse-order delete per batch, with hard-delete decision
Reconciliation reportCounts, samples, orphan checks per object

Package files