6

I am very new to SFDX and no sure if I get it right. We have existing instance of SF. It lives quite long time now and we have there loads of custom changes.

So I basically created unmanaged package with all those changes, create VS Code project, migrated data from unmanaged package to the project, created default scratch org and tried to push source code from project to the scratch org.

I got enormous list of errors, lot of them cannot be tracked down. If I'd try to do that incrementally, it would take me probably days. And I would be forced to do that for every new scratch org.

So I was wondering if there is any other way, how to create scratch org, which will be duplicate of my prod SF instance?

3 Answers 3

3

Salesforce DX does not provide a way to create a scratch org which contains a duplicate of your production instance. Each scratch org starts out empty so you will need to migrate your custom modifications manually. However in doing so you should not attempt to migrate everything all at once. The recommended approach is to do one module at a time. What you define as a module is up to you but generally it's considered to be a set of custom modifications that can be tested and deployed on it's own. You may still need to migrate each module incrementally but doing so should reduce the number of errors you need to work through.

2
  • This is a great answer. In addition, by module, we are talking about a set of code that will be Packaged - Unlocked (Beta/GA Oct '18) or Managed. Scratch Orgs were not built so you try to replicate a sandbox. Scratch Orgs were designed specifically with modular, package development in mind.
    – John Vogt
    Commented Jun 22, 2018 at 23:34
  • A lot has changed since this was first posted and answered. See Create an Org Shape command (currently in beta) that is intended to alleviate this exact pain point
    – bkwdesign
    Commented Nov 9, 2020 at 21:23
6

You should use Definition File when creating the scratch org to define its shape.

Currently preparing the shape definition file is a manual step. There is a pilot program which allows you to export the shape of an org and then you can feed that shape definition when you create the scratch org.

3

I recently started to evaluate Gearset.com. You might want to check it as the deployments seem to work just fine. Scratch orgs can be created and used as source/target. Data Deployment (in beta) to scratch orgs is not implemented yet, but seems to work for other targets (excl. production, of course). Instead of pushing "everything" to a scratch org you might want to use filter and pick up only the items that are needed for your current feature.

1
  • Jason from Gearset here. We released support for deploying data to scratch orgs yesterday. More to come in the coming weeks too!
    – Jason M
    Commented Feb 15, 2018 at 10:21

You must log in to answer this question.

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