Part-DB / Part-DB-server

Part-DB is an Open source inventory management system for your electronic components
https://docs.part-db.de/
GNU Affero General Public License v3.0
879 stars 96 forks source link

Invalid schema on fresh install #668

Closed bson closed 4 days ago

bson commented 1 month ago

Describe the bug

This is using the docker image at https://registry.hub.docker.com/r/jbtronics/part-db1/ on a Synology NAS. Configured the container to use a mysql server also on the NAS and started the partdb container. On the console ran the migration script, via: su www-data -c "php bin/console doctrine:migrations:migrate". On phpMyAdmin I can see 19 tables were created, with 9 rows in migrations, 2 users, and some other odds and ends. But when I try to connect with a browser it gives me a 500 error and "Infos for Admin: Invalid or not existing database schema."

One thing I noticed is that the instructions at: https://docs.part-db.de/installation/installation_docker.html Say it's available on port 8080, however the image exposes only port 80. I can connect this to an exposed port 8080, but I can't connect 8080 to 8080 because the latter is not listed in the image.

I think this is just a problem with the instructions though, and most likely the migration script doesn't properly initialize the database. It's also extremely slow, while just initializing a schema should take less than a second...

bson commented 1 month ago

Actually a small correction: I had to run the migration as root, because www-data isn't usable (it can't login):

root@jbtronics-part-db1-1:/var/www/html# su www-data -c 'php bin/console doctrine
:migrations:migrate'                                                             
This account is currently not available. 
bson commented 3 weeks ago

Okay, so I think I know approximately what the root cause of this is.

When I opened a terminal to the container I found a .env file in /var/www/html which had DATABASE_URL=sqllite://, BASE_CURRENCY=EUR and a bunch of other things different from the docker env. I recreated the container, changed this file to reflect my docker env, recreated the DB and reran the migration script. And now it works. So it seems like what happened was the migration script created a schema on mysql, but the server was trying to use a blank sqlite db.

I have to say, this is a total mess with env vars all over that just invites this kind of problems.