Skip to content

Restore storage.objects policies lost in the dev2 move - #262

Merged
ralyodio merged 1 commit into
masterfrom
fix/restore-dev2-lost-auth-storage
Sep 26, 2026
Merged

ralyodio merged 1 commit into
masterfrom
fix/restore-dev2-lost-auth-storage

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

Cause

On 2026-09-25 the Supabase project moved from Supabase cloud to the self-hosted stack on dev2. The move dumped DDL for the app schemas (public etc.) only. pg_dump files a policy under its table's schema, so every RLS policy ON storage.objects was lost, while the buckets (copied as data) survived. With RLS on and no policy, storage.objects denies every anon/authenticated read and write, so avatar uploads and encrypted-file uploads/downloads fail for everyone. The cloud project is deleted, so the migrations are the only source of truth.

What this restores

supabase/migrations/20260926210000_restore_storage_policies_lost_in_dev2_move.sql, idempotent (DROP POLICY IF EXISTS then CREATE POLICY), final state after replaying every migration in order. 14 policies on storage.objects:

  • avatars, from 20250823223015: "Users can upload their own avatar", "Users can update their own avatar", "Users can delete their own avatar", "Anyone can view avatars"
  • avatars, from 20250824005053: "Users can upload their own avatars", "Users can view all avatars", "Users can update their own avatars", "Users can delete their own avatars" (the fix drops only the plural names, so both sets existed)
  • encrypted-files, from 20250921060226: "Users can upload encrypted files", "Users can view encrypted files they have access to", "Users can delete their own encrypted files"
  • encrypted-files, from 20250926094631: "Users can upload files to encrypted-files bucket", "Users can view their own files in encrypted-files bucket", "Users can delete their own files in encrypted-files bucket"

Definitions are verbatim, except that the tables inside the encrypted-files SELECT policy are schema-qualified as public.* so the result does not depend on the search_path at apply time.

The repo never created a trigger on any auth.* or storage.* table, so there is no trigger to restore and no backfill.

Not yet applied to dev2; will be dry-run and applied from the operator session.

🤖 Generated with Claude Code

The 2026-09-25 move to the self-hosted stack on dev2 dumped DDL for the
app schemas only, so all 14 policies on storage.objects (avatars and
encrypted-files buckets) were dropped. This re-creates the final state
from the migrations, idempotently.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

ThreatCrush Security Scan

13 finding(s)

MEDIUM: 9 | LOW: 4

Severity Rule Location
MEDIUM redos-nested-quantifier src/app/api/profile/update/route.js:73
MEDIUM js-unescaped-html-sink src/app/blog/[slug]/page.jsx:38
MEDIUM js-unescaped-html-sink src/app/blog/[slug]/page.jsx:66
MEDIUM js-unescaped-html-sink src/app/faq/page.jsx:57
MEDIUM js-unescaped-html-sink src/app/layout.jsx:137
MEDIUM js-unescaped-html-sink src/app/layout.jsx:141
MEDIUM js-unescaped-html-sink src/app/page.jsx:47
MEDIUM redos-nested-quantifier src/lib/auth/dns-name.js:88
MEDIUM js-unescaped-html-sink src/lib/components/chat/MessageItem.jsx:60
LOW secret-generic-credential src/app/api/auth/register-anon/route.test.js:32
LOW secret-jwt tests/debug-sms.js:10
LOW secret-generic-credential tests/private-key-import-export.test.js:252
LOW secret-generic-credential tests/private-key-import-export.test.js:264

Snippets are redacted; ThreatCrush never prints matched credential material.

@ralyodio
ralyodio merged commit 0b1945d into master Sep 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant