karlomikus / bar-assistant

Bar assistant is a all-in-one solution for managing your home bar
https://barassistant.app
MIT License
587 stars 22 forks source link

Database Export/Import Broken again #351

Closed zhdenny closed 2 weeks ago

zhdenny commented 3 weeks ago

This issue exists on the very latest stable version you just published....but it was also present on your earlier version. I'm not sure how many versions back this issue has existed. It was just reported to me yesterday though.

Database export succeeds without an error message. Database import fails with error message.

SQLSTATE[23000]: Integrity constraint violation: 19 UNIQUE constraint failed: ingredients.slug

image

karlomikus commented 3 weeks ago

This looks like the bar you selected to import to already has data in it. Importing data needs empty bar at the moment.

zhdenny commented 3 weeks ago

This looks like the bar you selected to import to already has data in it. Importing data needs empty bar at the moment.

Oh I see. That is a new requirement/change I didn't know about.

Are there plans to bring this feature back to the way it was?

karlomikus commented 2 weeks ago

Actually it should just skip duplicates. The issue is in the matching of duplicates.

Recipe exporting is using the slug field from the database to create a "unique" ID, then importing is checking that value against "sluggified" ingredient name.

The issue happens because the slug field is not correct on export, therefor the export ID is not correct. For example in your export for ingredient: "Lemon Hart & Son 151 Rum" the id is "lemon-hart-son51-rum" which is wrong.

I'm not sure why the slug is not in sync with the actual ingredient/cocktail name because it should be, but that's beside the point.

I think I can fix it by updating the export logic to generate fresh slug from the name during the exporting.

zhdenny commented 2 weeks ago

Confirmed fixed with latest master release. Thank you man!