danielbrendel / hortusfox-web

Self-hosted collaborative plant management and tracking system for plant enthusiasts
https://www.hortusfox.com
MIT License
674 stars 34 forks source link

Rebuilding docker wipes out existing data in database #282

Closed F117aDriver closed 1 month ago

F117aDriver commented 1 month ago

Describe the bug My setup is running in docker on an Unraid system. When the hortusfox container is updated, the database initialization procedure seems to run, deleting and recreating the database tables and wiping out all current data. The database is in a separate mariadb docker container.

To Reproduce Steps to reproduce the behavior:

  1. Install docker container
  2. Save some locations, plants
  3. Rebuild the image/container and point it at the existing database
  4. POOF, all saved data is gone.

Expected behavior Initialization should check if data exists and not overwrite it.

Software: HortusFox v3.5 PHP Version: 8.3.0 MySQL Version: 10.11.8-MariaDB

Desktop (please complete the following information):

Appoxo commented 1 month ago

I am using the docker container from the repo ghcr.io/danielbrendel/hortusfox-web and the dockerhub mariaDB container mariadb:11.3
At least my container upgrade didnt nuke my database
My browser is firefox v131 on Win11

danielbrendel commented 1 month ago

Hi,

I am sorry for the inconvenience caused.

Are all tables re-created or just a few? If the first one is the case then it's likely because the migration.list wasn't taken into account for the migration process. The migration.list (located in /app/migrations) is a very crucial file that is used to determine what tables need to be created when using the "listly" migration type and it is normally bound to a volume.

When you say that you are using a "separate mariadb docker container": Does that mean you changed anything in the docker-compose.yml? Or the docker-compose.sh?

Message ID: @.***>

F117aDriver commented 1 month ago

No inconvenience! I love that you've created this project!

F117aDriver commented 1 month ago

I just confirmed that with this template, the migrations.list file is not bound to any volume so it doesn't persist. If this file is what prompts the system to re-create the tables then this is the source of the problem. I need to figure out how to persist that file in an "Unraid manner"...

F117aDriver commented 1 month ago

I reviewed the docker_compose.yml file and compared to the template on Unraid's docker repo and I think (I'm no way a docker expert) that the template is missing three volume mappings and I suspect the migrations one is causing my DB to get wiped out. I've add the mappings to my setup and we'll see how it goes and in the meantime, I may try to determine how to update the template on Unraid's repo.

This is not a bug with hortusfox. It's a malformed docker template in the Unraid docker repo.