This issue is now properly addressed in Salesforce DX. You need to set enableAccountHistoryTracking
to true
, as outlined in the Scratch Org Settings documentation:
{
"settings": {
"accountSettings": {
"enableAccountHistoryTracking": true
}
}
}
I've logged that bug with the DX team. The solution (for now) is to have an src directory in mdapi format, deploy the "history tracking" flag on the CustomObject first, and then deploy the fields afterwards.
sfdx force:mdapi:deploy -d src -w 10
sfdx force:source:push
Your src folder would be a traditional package:
src/package.xml
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Opportunity</members>
<name>CustomObject</name>
</types>
<version>42.0</version>
</Package>
src/objects/Opportunity.object
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<enableHistory>true</enableHistory>
</CustomObject>
Most of the fields are not necessary for standard objects, but be aware you have to specify things like label, fullName, pluralLabel, sharingModel, etc for custom objects.