With Platform.sh you can decide how you organize branches; the branches do not have to be strictly hierarchical. E.g.:
production
- develop
-- feature/xxx
- staging
-- feature/xxx
Let's say that production and stage are dedicated, the others are on-demand environments that can be temporary. This means you can also deploy from develop to production or add an emergency hotfix branch like so:
production
- hotfix/xxx
- develop
-- …
- staging
-- …
If you need to sync the database from staging to a dev branch, you can run this via the Platform.sh CLI and the platform db:dump and platform sql command. E.g.:
platform db:dump -e staging -f dump.sql
platform sql -e <DEV_ENVIRONMENT_NAME> < dump.sql
You can run this locally or in an application container (you need to install the Platform.sh CLI and have an Token set for this, see https://docs.platform.sh/administration/cli/api-tokens.html#on-a-platformsh-environment). If you expect the operation to run for longer, you can use nohup to make sure it runs even when you are disconnected.
This can even be triggered via a source operation. See https://docs.platform.sh/create-apps/source-operations.html for more details. Example config:
source:
operations:
sync-db:
command: |
curl -fsS https://platform.sh/cli/installer | php
/app/.platformsh/bin/platform db:dump -p ${PLATFORM_PROJECT} -e staging -f dump.sql
/app/.platformsh/bin/platform sql -e ${PLATFORM_BRANCH} < dump.sql
This operation can then be triggered via CLI (this one will dump data from stage to hotfix/test):
platform source-operation:run sync-db --variable env:PLATFORM_BRANCH="hotfix/test"
As an alternative, you can also trigger source operations via the UI. https://www.dropbox.com/s/407odu5483xecaf/Screenshot%202022-10-14%20at%2010.47.22.png?dl=0 https://www.dropbox.com/s/s2n20wtsdbcx37a/Screenshot%202022-10-14%20at%2010.47.03.png?dl=0
For the Platform CLI to work inside a source operation, you need a project variable env:PLATFORMSH_CLI_TOKEN with a token
It should also be possible to sync the files in the same way between dedicated environments or between dedicated and grid environments using the platform mount:download and platform mound:upload commands. Note: Using the sync of the mounts in a source operations would not be recommended, since the storage space inside the container that runs the source operation is limted.