From 51fdd0d5daa0f6a5f7c27d2ac2715129cfc90bdb Mon Sep 17 00:00:00 2001 From: Apple Date: Wed, 3 Dec 2025 10:12:21 -0800 Subject: [PATCH] feat: Add script to fix asset URLs after restore --- scripts/fix-asset-urls.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 scripts/fix-asset-urls.sh diff --git a/scripts/fix-asset-urls.sh b/scripts/fix-asset-urls.sh new file mode 100755 index 00000000..7112af61 --- /dev/null +++ b/scripts/fix-asset-urls.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Fix asset URLs after database restore +# Converts old /assets/ URLs to MinIO format + +set -e + +echo "🖼️ Fixing asset URLs..." + +docker exec daarion-postgres psql -U postgres -d daarion << 'EOF' +-- Fix logo URLs: convert old /assets/ URLs to MinIO format +UPDATE microdaos +SET logo_url = 'https://assets.daarion.space/daarion-assets/microdao/logo/' || slug || '.png' +WHERE logo_url IS NOT NULL + AND (logo_url LIKE '/assets/%' OR logo_url NOT LIKE 'https://%'); + +-- Clear invalid banner URLs +UPDATE microdaos +SET banner_url = NULL +WHERE banner_url IS NOT NULL + AND (banner_url LIKE '/api/static/%' OR banner_url NOT LIKE 'https://%'); + +-- Show results +SELECT + slug, + CASE WHEN logo_url LIKE 'https://%' THEN '✅ MinIO' WHEN logo_url IS NULL THEN 'NULL' ELSE '❌ Old' END as logo_status, + CASE WHEN banner_url LIKE 'https://%' THEN '✅ MinIO' WHEN banner_url IS NULL THEN 'NULL' ELSE '❌ Old' END as banner_status +FROM microdaos +ORDER BY slug; +EOF + +echo "✅ Asset URLs fixed" +