Skip to content

dify installation and upgrade

installation command

bash
helm repo add douban https://douban.github.io/charts/
helm upgrade dify douban/dify -n dify -f dify/dify-values.us1.yaml --install

Must run this migration command after upgrade

bash
kubectl exec -it dify-pod-name -- flask db upgrade

upgrade command

bash
helm diff upgrade dify douban/dify -n dify -f dify/dify-values.us1.yaml
bash
helm upgrade dify douban/dify -n dify -f dify/dify-values.us1.yaml

Must run this migration command after upgrade

bash
make kexec # select dify namespace and a worker pod

## when inside worker pod
flask db upgrade

Common Issues

Database Migration Conflicts

Issue: Flask migrations fail with "relation already exists" errors for sequences like task_id_sequence, taskset_id_sequence.

Root Cause: Celery workers start simultaneously with the API container and create database sequences before Flask migrations can run. The Helm chart lacks migration coordination.

Solution: If migrations fail, drop the entire database schema in dify_db databsae

bash
psql -h <psql-host> -U dify_user -d dify_db
psql
DROP SCHEMA public CASCADE; CREATE SCHEMA public;
bash
kubectl -n dify exec -it dify-worker-pod -- flask db upgrade

Prevention: Run migrations on existing pods before helm upgrades, or implement proper init containers for migration coordination.

Plugin Daemon SSL Connection Issue

Issue: Plugin daemon fails with no pg_hba.conf entry error when connecting to external PostgreSQL.

Root Cause: Plugin daemon requires SSL connection to external databases but defaults to non-SSL mode.

Solution: Add DB_SSL_MODE: "require" to plugin daemon environment variables.