Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix initial setup when using Postgres #392

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

501st-alpha1
Copy link

I ran into a few different issues when trying to run this locally in Docker (using Docker Compose as recommended).

The main problem is the migrations are not run on first docker-compose up, even if POPULATE_DATABASE is set to True. Searching through the issues I was able to find the command to run the migrations (bin/console doctrine:migrations:migrate --env=prod --no-interaction), and though it throws errors when run, the migrations do succeed. (Running the command a second time will show that no migrations need to be run, and no errors occur, so some part of the command must depend on having the correct database structure.)

I also noticed that the database-exists check was failing; when I did a fresh docker-compose up, the entrypoint.sh script detected that the wallabag database already existed, and I confirmed this by inspecting the Postgres instance myself. My guess is Docker Compose automatically created a database with the same name as the Compose project (which here was also wallabag), so by the time the script checks it already exists. To work around this, I instead added a check if any tables exist, and now it works properly.

One other issue I found is even though the entrypoint.sh provisioner runs the bin/console wallabag:install command, the default wallabag:wallabag user was not created. I ran the install command again by doing:

docker-compose exec wallabag php bin/console wallabag:install --env=prod -n

and after that the default user was created.

I haven't dug into either that or the migration command throwing errors, but will shortly either do so or at least create issues for them.

I found a few similar issues (listed below), but all of them have slight variations from my setup or behavior, e.g. using MySQL instead of Postgres, so I'm listing as Related rather than Fixes.

Related: #291, #236, #286, #154, #377.

This works better than checking just the database, because it could be
that an empty database has already been created (with e.g. Docker
Compose).

TABLES_EXIST should be empty if no tables, or will return a 1
for *each* table that exists.
This throws errors, but they can be ignored.
@j0k3r
Copy link
Member

j0k3r commented Jan 2, 2024

Every thing sound goods but now the build is failing. Can you look into it?

@j0k3r j0k3r requested a review from Kdecherf January 2, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants