docs/migration/server-pgvector-upgrade.mdx
The self-hosted Mem0 server has upgraded its PostgreSQL Docker image:
| Before | After | |
|---|---|---|
| Docker image | ankane/pgvector:v0.5.1 | pgvector/pgvector:pg17 |
| PostgreSQL | 15 | 17 |
| pgvector | 0.5.1 | 0.8.0 |
| Credentials | Hardcoded postgres / postgres | Set via POSTGRES_USER / POSTGRES_PASSWORD env vars |
No migration is needed. Copy the example env file, set your password, and start the stack:
cd server
cp .env.example .env
# Edit .env — set POSTGRES_PASSWORD (required) and OPENAI_API_KEY at minimum
make up
PostgreSQL 17 cannot read data files created by PostgreSQL 15 directly. You need to export your data from the old container and import it into the new one.
With the old stack still running:
cd server
docker compose exec -T postgres pg_dumpall -U postgres > mem0_backup.sql
Verify the dump is non-empty:
ls -lh mem0_backup.sql
docker compose down
docker compose down -v
.envPostgres credentials are no longer hardcoded in docker-compose.yaml. Add them to your .env:
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=<your-password> # required — compose will refuse to start without it
POSTGRES_COLLECTION_NAME=memories
Start only the Postgres container first — do not start the mem0 API yet.
The API runs alembic upgrade head on startup, which creates empty tables that
would conflict with the restore.
docker compose up -d postgres
Wait for Postgres to become healthy:
docker compose exec -T postgres pg_isready -q && echo "ready" || echo "not ready"
docker compose exec -T postgres psql -U postgres < mem0_backup.sql
You may see notices like role "postgres" already exists — these are safe to ignore.
Now start the mem0 API container. Alembic will detect the existing tables and only apply any new migrations:
docker compose up -d mem0
# Check service health
cd server && make health
# Confirm memories are accessible
curl -s http://localhost:8888/memories?user_id=<your-user-id> \
-H "X-API-Key: <your-api-key>"
If something goes wrong, revert the image tag in docker-compose.yaml:
postgres:
image: ankane/pgvector:v0.5.1
Then destroy the new volume, start the old image, and restore from your backup:
docker compose down -v
docker compose up -d --build
docker compose exec -T postgres psql -U postgres < mem0_backup.sql