5b30d0ca24
- Add 'food' category filter in ImageGallery component
- Add '🍽️ Food Gallery' section in sectionCategories
- Update filteredImages logic to handle food category
- Clean up duplicate logo/favicon images in database
20 lines
762 B
SQL
20 lines
762 B
SQL
-- Remove duplicate images, keeping only the most recent one per (filename, location_target, data length)
|
|
-- This handles upload accidents where same image was uploaded multiple times
|
|
|
|
-- First, identify duplicates
|
|
-- SELECT filename, location_target, COUNT(*) as dupes, array_agg(id) as ids
|
|
-- FROM images GROUP BY filename, location_target, LENGTH(data) HAVING COUNT(*) > 1;
|
|
|
|
-- Delete duplicates, keeping the latest (highest id) per group
|
|
DELETE FROM images a
|
|
USING images b
|
|
WHERE a.id < b.id
|
|
AND a.filename = b.filename
|
|
AND a.location_target = b.location_target
|
|
AND LENGTH(a.data) = LENGTH(b.data);
|
|
|
|
-- Verify cleanup
|
|
SELECT filename, location_target, COUNT(*) as count
|
|
FROM images
|
|
GROUP BY filename, location_target, LENGTH(data)
|
|
HAVING COUNT(*) > 1; |