mealie-recipes / mealie

Mealie is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend application built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the url and mealie will automatically import the relevant data or add a family recipe with the UI editor
https://docs.mealie.io
GNU Affero General Public License v3.0
5.62k stars 613 forks source link

Mealie to postgresql connect after database restart #3811

Open kuduacz opened 5 days ago

kuduacz commented 5 days ago

First Check

What is the issue you are experiencing?

when trying to start mealie docker container connected do postgresql app crush after database restart. here's logs: DETAIL: Key (id)=(21bc813e-1f44-42cc-9641-0e3b723d6e3a) is still referenced from table "shopping_lists_multi_purpose_labels". [SQL: DELETE FROM multi_purpose_labels WHERE id=%(id)s::UUID] [parameters: {'id': UUID('21bc813e-1f44-42cc-9641-0e3b723d6e3a')}] (Background on this error at: https://sqlalche.me/e/20/gkpj) ERROR 2024-06-28T08:39:06 - Application startup failed. Exiting. usermod: no changes Switching to dedicated user User uid: 1000 User gid: 1000

Docker compose file: name: mealie services: mealie: cpu_shares: 90 command: [] container_name: mealie deploy: resources: limits: memory: "16538140672" reservations: memory: "536870912" environment: ALLOW_SIGNUP: "true" BASE_URL: http://192.168.x.xx DB_ENGINE: postgres MAX_WORKERS: "1" PGID: "1000" POSTGRES_URL_OVERRIDE: ***correct path because it work PUID: "1000" TZ: Europe/Warsaw WEB_CONCURRENCY: "1" hostname: mealie image: ghcr.io/mealie-recipes/mealie:latest

Steps to Reproduce

--

Please provide relevant logs

--

Mealie Version

latest version of imgae

Deployment

Docker (Linux)

Additional Deployment Details

--

michael-genson commented 5 days ago

Do you have a backup file you could share? Looks like a bug with one of our migrations that I'd like to debug.

To fix your instance, if you manually delete that label and the entry on the shopping_lists_multi_purpose_labels table that references that label you should be fine. One of our migrations is supposed to do that for you.

kuduacz commented 2 days ago

Do you have a backup file you could share? Looks like a bug with one of our migrations that I'd like to debug.

To fix your instance, if you manually delete that label and the entry on the shopping_lists_multi_purpose_labels table that references that label you should be fine. One of our migrations is supposed to do that for you.

mealie_2024.06.25.10.58.40.zip

Hey michael. In attachment You will find my backup. Could you provide more detailed instructions to fix it? I'm not a very advanced postgresql user.

michael-genson commented 2 days ago

It looks like the label "Przyprawy" is in there twice. If you're not comfortable editing the db directly, you can edit the backup JSON and just restore from the edited JSON.

First, delete the multi_purpose_labels object with the id of 21bc813e1f4442cc96410e3b723d6e3a Then, delete the shopping_lists_multi_purpose_labels object with the id of 23eeab06a7e849b6905f818fa47c8416

Then restore the backup. If you're not sure how to edit the JSON let me know.

kuduacz commented 1 day ago

additional knowledge is always welcome so I'd love to learn how to do it.

michael-genson commented 1 day ago

After you access your postgres db, you want to drop the rows with those ids from those tables. So you'd want to run these two SQL queries:

DELETE FROM multi_purpose_labels WHERE id = '21bc813e1f4442cc96410e3b723d6e3a';

DELETE FROM shopping_lists_multi_purpose_labels WHERE id = '23eeab06a7e849b6905f818fa47c8416';

I'd strongly recommend backing up your db before running any queries