- Manually
- With Drupal and Drush
To sanitize your database and get rid of sensitive, live information, use the More options are available.
These are described in the Drush documentation.To sanitize only on the initial deploy and not all future deploys,
use Drush state as in the following example:
drush sql:sanitize command.
Add your script to sanitize the database to a deploy hook
for preview environments:.upsun/config.yaml
Copy
Ask AI
applications:
myapp:
hooks:
deploy: |
# ...
cd /app/public
if [ "$PLATFORM_ENVIRONMENT_TYPE" = production ]; then
# Do whatever you want on the production site.
else
drush -y sql:sanitize
fi
drush -y updatedb
.upsun/config.yaml
Copy
Ask AI
applications:
myapp:
hooks:
deploy: |
# ...
cd /app/public
if [ "$PLATFORM_ENVIRONMENT_TYPE" = production ] || [ "$(drush state:get --format=string mymodule.sanitized)" != yes ]; then
# Do whatever you want on the production site.
else
drush -y sql:sanitize
drush state:set --input-format=string mymodule.sanitized yes
fi
What’s next
If your database contains a lot of data, consider using theOPTIMIZE TABLE statement
to reduce its size and help improve performance.