I am trying to create a scratch org. My codebase is having a class which is doing a dml on accountshare record. For deployment of this class we need to have account's OWD as private. (As well as of contact, case and opprotunity). So I made changes in Account Account.object-meta.xml. and made sharing model as private.
`<?xml version="1.0" encoding="UTF-8"?> <CustomObject xmlns="http://soap.sforce.com/2006/04/metadata"> <compactLayoutAssignment>SYSTEM</compactLayoutAssignment> <enableFeeds>true</enableFeeds> <enableHistory>false</enableHistory> <recordTypeTrackFeedHistory>false</recordTypeTrackFeedHistory> <sharingModel>Private</sharingModel> </CustomObject> `
Same for case, opportunity and contact. But still while deploying I am getting this error
DML operation Delete not allowed on List<AccountShare>
I can comment the dml operations and deploy it.
After first deployment subsequent deployments works fine even with AccounShare Code uncommented.
How we can fix this problem without having to do any manual work.