Silent pg_restore Bug Can Lose Entire Tables When Restoring Supabase Backups
A developer discovered that restoring a Supabase database backup using standard pg_restore can silently drop entire tables without raising a fatal error. The issue occurs because Supabase-specific functions like auth.uid(), commonly used as column defaults, fail when restored into a plain PostgreSQL environment that lacks the auth schema. By default, pg_restore logs these errors but continues execution, leaving the affected tables and their data absent from the restored database. The bug is particularly dangerous because developers testing Supabase backups are already conditioned to ignore auth-related errors, making missing tables easy to overlook. The fix involves creating stub roles and a minimal auth schema in the target database before running pg_restore, ensuring dependent objects resolve correctly during restoration.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in