# exit on error
set -o errexit


export DJANGO_SETTINGS_MODULE={{cookiecutter.project_slug}}.settings_production


echo "Running database migrations"
python manage.py migrate
```

Finally, add the following line to your `render.yaml` file, after the `buildCommand`:

```yaml
    preDeployCommand: "./deploy/pre_deploy.sh"
```

After completing these steps, migrations will run in the pre-deploy phase.

### Settings and Secrets

[Section titled “Settings and Secrets”](#settings-and-secrets)

Render builds use the `settings_production.py` file. You can add settings here or in the base `settings.py` file, and use environment variables to manage any secrets, following the examples in these files.

Environment variables can be managed from the “Environment” tab on your app’s dashboard.

### Running One-Off Commands

[Section titled “Running One-Off Commands”](#running-one-off-commands)

You can run one-off commands in the Render shell (paid plan required) or [via SSH](https://render.com/docs/ssh).

### Celery Support

[Section titled “Celery Support”](#celery-support)

To run celery workers on Render you will need to upgrade to a paid plan.

Then in your `render.yaml` file uncomment the ‘celery’ section and rebuild from the steps above.

If you previously deployed your application you can choose “Update Existing Resources” to avoid having to recreate your app / database / redis instance.

### Troubleshooting

[Section titled “Troubleshooting”](#troubleshooting)

**Sometimes Render fails to build on the first deployment.** Retrying the deployment from the same commit seems to resolve this.

### Container-based deployment

[Section titled “Container-based deployment”](#container-based-deployment)

It is possible to use Render’s docker-based support to deploy Pegasus apps, but it is not recommended because there is no “release” phase, which makes it difficult to set up things like database migrations.

More details can be found in [this support thread](https://community.render.com/t/release-command-for-db-migrations/247/7).