Environments as a concept is quite well documented. What Iām missing is a recommended development workflow and Iāve been missing it since 2023 ![]()
Letās say you have turned on Force the use of sandbox environments to enforce that each schema change must be handled via a migration. Then the simplest development workflow that I can think of looks like this:
- Make a fork of primary environment and a corresponding feature branch in git
- Make schema changes in the sandbox environment and update code on the feature branch to work with new changes
- While developing you must occasionally run migrations on the sandbox environment to make sure it is up to date with other changes that may have been applied to primary
- Add content to the sandbox environment to verify that the feature works like it should
- When feature is done, generate migrations to record the schema changes made from this branch
The deployment steps will be
- Turn on maintenance mode in DatoCMS
- Apply the migrations to primary to create a new sandbox environment
- Copy paste the content from the old sandbox environment to the new sandbox environment
- Test that everything works
- Merge the feature branch in git
- Promote the new environment to primary
- Deploy the code changes to production
- Turn off maintenance mode
This is not trivial! And there are also some risky bits such as
- If the site is not entirely static but make Dato-requests at runtime then there is a risk that the production site start to fail, between the promotion of the new primary and the deploy of the new code, if the schema changes were not backwards compatible.
- If the content is complex there is a lot of copy paste especially if there are multiple languages involved.
I feel that you have probably worked internally to optimize the above workflow for your own use case and Iām sure you there are best practices that you can share. Perhaps the migration can be run with a Github action as part of the deploy process? Perhaps there is another way to structure work that reduces the number of steps?
Regardless I think it would be nice for existing and new users alike if you could add dev process examples to the help page: Primary and sandbox environments ā DatoCMS