Read the screenplay: FANNIEGATE — $7 trillion. 17 years. The biggest fraud in American capital markets.
#35🚀 DeploymentPainful

Force-Pushing Source That Overwrites Production Customizations

Your local source is not the source of truth. Production is.

What Happened

An admin had added five new fields and two validation rules directly in production (yes, I know). I retrieved my project source from my sandbox, which was three weeks stale, and deployed to production. My package.xml included the full object definition. All the admin's fields and validation rules vanished. The admin had been building reports on those fields. I got a very pointed email at 7 AM the next morning.

The Wrong Way

# Retrieve from stale sandbox
sf project retrieve start -o MyStaleSandbox -x manifest/package.xml

# Deploy everything to prod without checking what's already there
sf project deploy start -x manifest/package.xml -o production --test-level RunLocalTests
# This overwrites any metadata in prod that's in your package.xml

The Right Way

# 1. Always retrieve from PRODUCTION first to get current state
sf project retrieve start -o production -x manifest/package.xml

# 2. Compare what you're about to deploy
sf project deploy start -d force-app -o production --dry-run --test-level RunLocalTests

# 3. Review the deployment plan - check for overwrites
# Look at the component list and verify each one

# 4. Use specific component deploys instead of full object deploys
sf project deploy start \
  -d force-app/main/default/classes/MyNewClass.cls \
  -d force-app/main/default/classes/MyNewClassTest.cls \
  -o production --test-level RunSpecifiedTests --tests MyNewClassTest

# 5. Retrieve from prod AFTER deploy to sync your local source
sf project retrieve start -o production -x manifest/package.xml

The Lesson

Always retrieve from production before deploying to it. Deploy specific components, not entire objects. Production is the source of truth until you have proper source control.

Don't make this mistake.

Hire someone who already did.

View Consulting →

Enjoyed this? Get more like it.

Glen's Musings — AI, investing, and building things. Occasional. Free.

More Deployment Mistakes