2

I created a custom object, but later decided to add a custom record type for the Case object instead. It's easy to remove the object in my scratch org, but removing it doesn't remove the corresponding metadata from my local DX project when I execute a sfdx force:source:pull --forceoverwrite.

Is there a way to mirror metadata deletions, or does it only work for creates and updates?

1 Answer 1

2

To delete whatever (e.g. a custom object), use force:source:delete. This removes the metadata from both your repo and the scratch org.

sfdx force:source:delete -p force-app/main/default/objects/MyCustomObject__c

As far as I can tell, you can only track created and updated metadata, not deleted metadata.

4
  • 1
    Ah, so not so much a "source of truth" after all huh? Let's just keep our trash around in production as we delete things from git :') Commented May 31, 2022 at 14:34
  • @ToonAlfrink it's more like Salesforce is really careful to avoid accidently deleting subscriber records by accident. It is intentional that one needs to delete fields and objects explicitly.
    – sfdcfox
    Commented May 31, 2022 at 17:20
  • I find that to be unnecessary hand holding. Why do they assume that I'm not careful with pushing things to master? Commented Jun 1, 2022 at 7:49
  • @ToonAlfrink They don't assume that you, or any specific person, won't be careful, they just assume that humans tend to make mistakes from time to time. I've met plenty who have made at least one mistake. I guess they're overkill, since you can technically just go in and undelete an object/field, but they've always been a bit paranoid about customer data.
    – sfdcfox
    Commented Jun 1, 2022 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .