Incompatible PostgreSQL Version
After I updated Docker, when I tried to wasp start db I get the error below:
PostgreSQL Database directory appears to contain a database; Skipping initialization
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 16, which is not compatible with this version 17.2 (Debian 17.2-1.pgdg120+1).
wasp-bin: callCommand: docker run --name wasp-dev-db-XXX-XXX --rm --publish 5432:5432 -v wasp-dev-db-XXXX-86b4beda11:/var/lib/postgresql/data --env POSTGRES_PASSWORD=XXXXXX --env POSTGRES_USER=XXXXXX --env POSTGRES_DB=XXXX-XXXXX postgres (exit 1): failed
Is there a solution for this?
2 Replies
Hi @Rafael Pettersen. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
This issue appears to be related to a version mismatch between the PostgreSQL database files and the server version after a Docker update. Based on the information provided in the knowledge sources, I can offer some potential solutions:
1. Delete the existing Docker volume:
The error suggests that the database files were initialized with PostgreSQL version 16, but the current server is version 17.2. To resolve this, you can try deleting the existing Docker volume and letting Wasp create a new one. You can do this by running:
Replace "XXXX-86b4beda11" with the actual volume name from your error message.
2. Use a specific PostgreSQL version:
Instead of using the latest PostgreSQL image, you can specify a version that matches your existing database files. You can do this by running a custom Docker command:
This command is based on the suggestion from this Discord thread (https://discord.com/channels/686873244791210014/1179895919471247490).
3. Update your project's PostgreSQL version:
If you want to use the latest PostgreSQL version, you may need to update your project's configuration and potentially migrate your data. However, this process is not detailed in the provided knowledge sources.
4. Check for Wasp updates:
Ensure you're using the latest version of Wasp, as there might be updates that address compatibility issues with newer Docker/PostgreSQL versions.
If these solutions don't work, you may need to seek further assistance. The Wasp community on Discord or GitHub issues might be able to provide more specific guidance for your situation.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Rafael Pettersen, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?
Oh yes, we always use the latest Postgres version. And your dev DB was created while we were using version 16, and now Postgres is at 17. We should pin down Wasp's dev DB version so it doesn't change that often: https://github.com/wasp-lang/wasp/issues/1606
The solution would be to go into Docker Desktop / or however you manage Docker and delete the database volume.
Or just run
docker volume ls | grep 86b4beda11
(I'm using your hash 86b4beda11
) and find the full name.
Then run docker volume rm <full-name>
cc: @martinsosGitHub
Pin down postgres version in managed dev db · Issue #1606 · wasp-la...
Right now in our managed dev db we use docker image postgres:latest, which means at some point, version of postgres changes, and your local dev database might now work with it. At that moment you h...