bug: Migration fails if "logto" DB already exists
Describe the bug
If the "logto" DB already exists in an otherweise empty Postgres DB, then migrations don't continue. Many times the DB is already provisioned (like in a managed DB, or if defined via POSTGRES_DB: "logto"
Expected behavior
The Migration should continue if the DB already exists. If there are any tables in that DB, then the migration should stop probably.
How to reproduce?
Add the following config to the provided docker-compose.yml file
environment:
POSTGRES_USER: "logto"
# Can't be defined, because logto wants to create it
#POSTGRES_DB: "logto"
Context
OS: Linux Environment: Docker Compose Logto version: ghcr.io/logto-io/logto:1.0.0-beta.6
Hi @flobaader , thanks for reporting.
And yes, this is an acknowledged issue and it has caused confusion several times to others as well.
However, this is actually "by design". When we were writing the script we thought it would be clean and safer if the database was empty, and TBH it was also easier to implement.
But now we think you concern is valid and we'll try to update the script to avoid this. For the time being, you will still have to provide a clean DB when initializing it. I'm sorry for the inconvenience and we will see what we can do to improve.
Thanks, Charles
Btw, our docker compose is not for production usage, as a new Postgres instance will be created every time, and you will lose your data previously persisted.
Alright thank you!
Btw, our
docker composeis not for production usage, as a new Postgres instance will be created every time, and you will lose your data previously persisted.
It is true that Logto's docker-compose.yml file is not currently configured to persist the database and it is recreated every time, but when I use it myself, I configure the persistence of the postgres data, so when the app service restarts every time for some reason, the postgres service logs get an ERROR: database "logto" already exists error log.
Personally, I think Logto definitely needs database persistence for actual use, otherwise it's a demo and not capable of production use.
Of course I'm just a personal suggestion, and I'm not sure about your design logic, either way, we're all here to make Logto great!