Closed 401557122 closed 2 months ago
To migrate data from version 0.6.9 to version 0.7.0 in a self-hosted Dify setup using Docker, follow these documented steps:
Enter the docker directory of the Dify source code:
cd dify/docker
Bring down the current Docker containers:
docker compose down
Pull the latest changes from the main branch:
git pull origin main
Pull the latest Docker images:
docker compose pull
Bring up the Docker containers with the new version:
docker compose up -d
These steps will handle the upgrade process, including any necessary data migrations [1].
To continue talking to Dosu, mention @dosu.
I need to migrate data, but the data table structure is different in these two versions. I copied the volume directly and encountered an error when starting @dosu
To migrate data when the data table structure is different between version 0.6.9 and version 0.7.0 in a self-hosted Dify setup using Docker, follow these steps:
Review Changes: Familiarize yourself with the new .env
configuration and Docker Compose setup.
Transfer Customizations:
docker-compose.yaml
, ssrf_proxy/squid.conf
, or nginx/conf.d/default.conf
, reflect these changes in the .env
file you create.Data Backup:
dify/docker/volumes
directory if deployed in Docker Compose mode.Update and Migrate:
Pull the latest code or images:
git pull origin main
docker compose pull
Bring down the current Docker containers:
docker compose down
Bring up the Docker containers with the new version:
docker compose up -d
Database Migration:
flask db upgrade
The migration script for version 0.7.0 includes creating new tables and indices, as well as dropping obsolete tables and indices [1][2][3].
To continue talking to Dosu, mention @dosu.
It seems that there are some account password information stored in my old version of Volume. I found that when I migrated the data, if I modify the account password information in the configuration of the new version, it will appear that these information are inconsistent in the environment variables and data volume @dosu.
To handle inconsistencies between account password information in the environment variables and data volume during a migration, follow these steps:
Backup Data: Ensure you have a backup of your current data volume.
Review Environment Variables: Verify the environment variables related to account passwords in your .env
file. These include:
INIT_PASSWORD
DB_PASSWORD
REDIS_PASSWORD
CELERY_BROKER_URL
QDRANT_API_KEY
MILVUS_PASSWORD
CHROMA_AUTH_CREDENTIALS
ORACLE_PWD
Update Environment Variables: Ensure that the values in your .env
file match the expected values for the new version. Update them if necessary.
Migrate Data:
Bring down the current Docker containers:
docker compose down
Pull the latest code or images:
git pull origin main
docker compose pull
Bring up the Docker containers with the new version:
docker compose up -d
Database Migration:
flask db upgrade
Update Account Passwords: If there are inconsistencies, you may need to manually update the account passwords in the database to match the new environment variables. Use the update_account_password
method from the AccountService
class to ensure passwords are hashed and salted correctly.
By following these steps, you can ensure that the account password information is consistent between the environment variables and the data volume [1][2][3].
To continue talking to Dosu, mention @dosu.
I changed the account password in env, how to change it in volume @dosu.
To change the account password in the volume after updating it in the environment variables, you need to update the password directly in the database. You can use the reset-password
command provided in the Dify repository. Here are the steps:
Enter the Docker container:
docker exec -it <container_name> /bin/bash
Run the reset-password
command:
flask reset-password --email <your_email> --new-password <new_password> --password-confirm <new_password>
This command will update the account password in the database to match the new password specified in the environment variables. Make sure to replace <container_name>
, <your_email>
, and <new_password>
with the appropriate values.
Here is the relevant code for the reset-password
command:
@click.command("reset-password", help="Reset the account password.")
@click.option("--email", prompt=True, help="The email address of the account whose password you need to reset")
@click.option("--new-password", prompt=True, help="the new password.")
@click.option("--password-confirm", prompt=True, help="the new password confirm.")
def reset_password(email, new_password, password_confirm):
"""
Reset password of owner account
Only available in SELF_HOSTED mode
"""
if str(new_password).strip() != str(password_confirm).strip():
click.echo(click.style("sorry. The two passwords do not match.", fg="red"))
return
account = db.session.query(Account).filter(Account.email == email).one_or_none()
if not account:
click.echo(click.style("sorry. the account: [{}] not exist .".format(email), fg="red"))
return
try:
valid_password(new_password)
except:
click.echo(click.style("sorry. The passwords must match {} ".format(password_pattern), fg="red"))
return
# generate password salt
salt = secrets.token_bytes(16)
base64_salt = base64.b64encode(salt).decode()
# encrypt password with salt
password_hashed = hash_password(new_password, salt)
base64_password_hashed = base64.b64encode(password_hashed).decode()
account.password = base64_password_hashed
account.password_salt = base64_salt
db.session.commit()
click.echo(click.style("Congratulations! Password has been reset.", fg="green"))
This will ensure that the password is updated correctly in the database [1].
To continue talking to Dosu, mention @dosu.
Including the account password for Postgres, the volume I migrated seems to have a password, but the new version of env wants to change it @dosu.
To update the Postgres account password in the volume after changing it in the environment variables, follow these steps:
Update the POSTGRES_PASSWORD
Environment Variable:
Update the POSTGRES_PASSWORD
environment variable in your docker-compose.yaml
file or in the environment variables file (e.g., .env
).
Example in the .env
file:
POSTGRES_PASSWORD=newpassword123
Restart the db
Service:
Restart the db
service to apply the new password.
Example docker-compose.yaml
:
services:
db:
image: postgres:15-alpine
restart: always
env_file:
- ./middleware.env
volumes:
- ./volumes/db/data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD", "pg_isready" ]
interval: 1s
timeout: 3s
retries: 30
Restart the service:
docker compose down
docker compose up -d db
Manually Update the Postgres Password in the Database: Enter the Postgres container and update the password directly in the database.
docker exec -it <postgres_container_name> psql -U postgres
Once inside the Postgres shell, run:
ALTER USER postgres WITH PASSWORD 'newpassword123';
Replace <postgres_container_name>
with the actual name of your Postgres container and newpassword123
with your new password.
By following these steps, you ensure that the Postgres password is updated both in the environment variables and directly within the database [1][2][3][4][5].
To continue talking to Dosu, mention @dosu.
Please use Discussion for asking help. This is a template for issue report.
Self Checks
Dify version
0.7.0
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
How to migrate data from version 0.6.9 to system 0.7.0
✔️ Expected Behavior
No response
❌ Actual Behavior
No response