Files
route-commerce/supabase/migrations/.archived/087_brand_logos_bucket.sql
T
openclaw c86e97e816
Deploy to route.crispygoat.com / deploy (push) Failing after 7s
feat(storage): MinIO object storage, Neon Auth, Supabase removal
- Add MinIO/S3-compatible storage client (src/lib/storage.ts) with uploadObject,
  deleteObject, presigned URL helpers, and BUCKETS constant
- Wire product images, brand logos, and water log photos to MinIO via the
  new storage client
- Migrate forgot-password to Neon Auth (remove Supabase /auth/v1/recover call)
- Migrate send-scheduled cron to direct Postgres + Resend (remove Supabase Edge
  Function proxy)
- Add logoUrl to email types (OrderReceipt, Welcome, PasswordReset) and pass
  brand_settings.logo_url from all call sites
- Update email templates to use dynamic logoUrl instead of hardcoded Supabase
  bucket URLs
- Remove hardcoded Supabase URLs from TuxedoVideoHero, TuxedoAboutPage,
  TimeTrackingFieldClient; use brand_settings props + local public/ fallback
- Download brand logos (3) and tuxedo-hero.mp4 (36MB) from Supabase bucket to
  public/ for local development
- Add MinIO env vars to .env.example (endpoint, access key, secret, buckets)
- Fix TimeTrackingFieldClient to destructure logoUrl and brandAccent props
- Fix admin/users.ts logoUrl type (null → undefined for optional string)
- Remove stale sb- cookie from wholesale-auth
- Migrate tuxedo/about page to remove supabase import and use pool query for
  wholesale_settings lookup
2026-06-09 12:21:57 -06:00

77 lines
2.0 KiB
SQL

-- Migration 087: Brand Logos Storage Bucket
--
-- SETUP REQUIRED (one-time, run manually in Supabase dashboard):
-- 1. Go to Storage → New bucket
-- 2. Name: "brand-logos" | Public: true
-- 3. Allowed MIME types: image/png, image/jpeg, image/webp, image/svg+xml
-- 4. Max file size: 5MB
--
-- Files stored at: brand-logos/{brand_id}/logo.png, brand-logos/{brand_id}/logo-dark.png
-- RLS policies for brand-logos bucket
-- Brand admins can upload/update their own brand's logos
-- Everyone can read logos (public bucket)
CREATE POLICY IF NOT EXISTS "brand_admin_upload_logo"
ON storage.objects
FOR INSERT
WITH CHECK (
bucket_id = 'brand-logos'
AND (
-- Platform admin can upload to any brand
EXISTS (
SELECT 1 FROM admin_users au
WHERE au.user_id = auth.uid() AND au.role = 'platform_admin'
)
OR
-- Brand admin can upload to their own brand's folder
(storage.foldername(name))[1] IN (
SELECT au.brand_id::text FROM admin_users au
WHERE au.user_id = auth.uid()
AND au.role = 'brand_admin'
)
)
);
CREATE POLICY IF NOT EXISTS "public_read_logo"
ON storage.objects
FOR SELECT
USING (bucket_id = 'brand-logos');
CREATE POLICY IF NOT EXISTS "brand_admin_update_logo"
ON storage.objects
FOR UPDATE
USING (
bucket_id = 'brand-logos'
AND (
EXISTS (
SELECT 1 FROM admin_users au
WHERE au.user_id = auth.uid() AND au.role = 'platform_admin'
)
OR
(storage.foldername(name))[1] IN (
SELECT au.brand_id::text FROM admin_users au
WHERE au.user_id = auth.uid()
AND au.role = 'brand_admin'
)
)
);
CREATE POLICY IF NOT EXISTS "brand_admin_delete_logo"
ON storage.objects
FOR DELETE
USING (
bucket_id = 'brand-logos'
AND (
EXISTS (
SELECT 1 FROM admin_users au
WHERE au.user_id = auth.uid() AND au.role = 'platform_admin'
)
OR
(storage.foldername(name))[1] IN (
SELECT au.brand_id::text FROM admin_users au
WHERE au.user_id = auth.uid()
AND au.role = 'brand_admin'
)
)
);