I am just starting out with my first migration using the salesforce org development model in VS Code. I pulled in my project from my sandbox environment and made my changes and deployed my file back to the org. Now I want to deploy this same change to another org. Do I just need to authorize that org in VS Code and deploy that same change to the new org? Or do I need to authorize the new org, pull all the code from that org and then make the change again? I am just unsure how this is all suppose to work deploying through multiple org. In the end I want to be able to migrate this change to my production org.
1 Answer
Do I just need to authorize that org in VS Code and deploy that same change to the new org?
Yes, that's correct. You do not need to pull the code from your other org and re-make the changes there. Your source code is a representation of the metadata that can be pushed to any org (subject to dependencies).
However, it's important to be aware of a couple of things.
- VS Code/Salesforce DX don't do any merging of metadata for you. If your other org contains different changes to the same classes or metadata entities than the changes you just made, you'll lose those other changes. Put a different way, the end result in Other Org is that each deployed entity will look exactly like what you have in VS Code, regardless of what used to be in Other Org.
- VS Code does manifest-based deployments against your default org. Once you authorize your new org, make sure to set it as your default (
> SFDX: Set a Default Org
) to make it the target of manifest-based deploys.
See the Org Development Model documentation for more.
-
Just to clarify on point 1. I started off my pulling from my sandbox org. I made a change to a specific trigger class file. I know want to migrate this change to production. I plan to just right click the file and click on deploy to server in VS code. Will this just send that files changes to production (that is what I want) or will it send anything that has changed in the entire project? This sandbox might have other changes not in production and I don't want them to move. Apr 4, 2019 at 13:47
-
When you deploy metadata from Visual Studio Code, you are no longer touching the sandbox. Your only concern is the specific metadata in your VSC project. However, you'll have to ensure that you connect to your prod org and construct a deployment that meets the Salesforce code coverage requirements. That's going to be past the scope of a comment so you may need to open another question if you need more on that topic.– David Reed ♦Apr 4, 2019 at 13:56
-
Just to clarify my point. I originally pulled the project from sandbox (this environment has other changes not in production) and I changed 1 class file in VS Code. Some other class files are different in this project than production, but I plan to only right click on the specific file I want to migrate with a deploy to server. Will all the other class files that are different get pushed to production as well? I hope that makes sense. Apr 4, 2019 at 14:09
-
I believe that's how it works, yes, but I rarely use VSC in org-based development. In any case, such an action may not succeed because you must meet code coverage requirements.– David Reed ♦Apr 4, 2019 at 14:37