Migration to PostgreSQL
As of version 0.19.0
, Agenta is transitioning from MongoDB to PostgreSQL.
Users need to migrate their MongoDB databases to this latest version, as this
will be the only version receiving feature updates and patches.
This guide provides step-by-step instructions for migrating your agenta instance from MongoDB to PostgreSQL version.
Prepare for Migration
Before starting the migration, ensure that you have backed up your production data.
While the migration will not modify any data in your MongoDB instance, it is highly recommended that you create a backup of your database in the MongoDB instance before running the migration script. This ensures you have a recovery point in case of any issues.
Start the Migration
- Start the local instance of Agenta using the dedicated migration Docker Compose file, and ensure that both the MongoDB and PostgreSQL instances are active.
cd agenta-backend/agenta_backend/migrations/mongo_to_postgres
docker compose -f docker-compose.migration.yml up
- Use the following commands to initiate the migration:
docker ps
The above command will list the running docker containers that you have. Copy the backend container id and execute bash.
docker exec -it {backend-container-id} bash
Next, navigate to the mongo_to_postgres
folder to execute the migration script.
cd /app/agenta_backend/migrations/mongo_to_postgres
python3 migration.py
Post Migration
After completing the migration, ensure you check the data integrity in PostgreSQL by accessing Agenta on the web and verifying that your data is intact and everything works fine.
In the event that you encounter issues and need to revert the migration, rest assured that your data in the MongoDB instance is still intact. All you need to do to revert is to check out the last commit you were on before the PostgreSQL migration and create a Github issue describing the problem you encountered.