# Commands

## 1. Generate Backfill Dataset

```bash
python3 scripts/salesforce_migration/export_reconcile_missing_records.py \
  --config ~/.salesforce/readonly_config \
  --reconcile-summary docs/migration/2026-05-25-212801-prod-reconcile-gap-backfill/reconcile-mismatch-summary.json \
  --output-root .tmp/prod-reconcile-gap-backfill \
  --snapshot-date 2026-05-25 \
  --run-label prod-reconcile-gap-backfill-batch1 \
  --db-host "$TIDB_PROD_HOST" \
  --db-port "$TIDB_PROD_PORT" \
  --db-user "$TIDB_PROD_USER" \
  --db-password "$TIDB_PROD_PASSWORD" \
  --db-database "$TIDB_PROD_DATABASE" \
  --objects Account,Contact,Lead,CampaignMemberStatus,Quote,OpportunityLineItem,Order,OrderItem,OpportunityContactRole,Opportunity_Product__c,Quote_Product__c,Order_Product__c,PoC__c,org__c,AccountShare
```

## 2. Load Generated Dataset

```bash
python3 scripts/salesforce_migration/load_salesforce_snapshot_to_tidb.py \
  --snapshot-dir .tmp/prod-reconcile-gap-backfill/2026-05-25/prod-reconcile-gap-backfill-batch1 \
  --manifest-name manifest.json
```

## 3. Post-Load Verification

```bash
python3 scripts/salesforce_migration/verify_latest_snapshot_vs_tidb.py \
  --snapshot-root /home/ec2-user/sf-export \
  --object Account \
  --object Contact \
  --object Lead \
  --object CampaignMemberStatus \
  --object Quote \
  --object OpportunityLineItem \
  --object Order \
  --object OrderItem \
  --object OpportunityContactRole \
  --object Opportunity_Product__c \
  --object Quote_Product__c \
  --object Order_Product__c \
  --object PoC__c \
  --object org__c \
  --object AccountShare
```

## Notes

1. The first command recomputes the full missing-ID set live from Salesforce and TiDB, then generates the import dataset.
2. The second command performs the actual TiDB load and must run with the
   correct production DB credentials.
3. `CampaignMember` is intentionally excluded from the first batch because the
   missing-only volume is large and should be handled as a dedicated follow-up
   import.
