| name | Supabase |
| description | Supabase migration safety, local testing workflow, grant requirements, fallback observability, and health endpoint patterns. |
Supabase
Migration Testing
Wrong -- push migration directly to remote:
supabase db push
Right -- test locally first:
supabase start
supabase db reset
docker exec supabase_db_<project> psql -U postgres -c "SELECT * FROM new_table LIMIT 1;"
supabase db push
Table Grants
Wrong -- create table without grants (RLS blocks access):
CREATE TABLE public.posts (id uuid PRIMARY KEY, title text NOT NULL);
Right -- include explicit grants:
CREATE TABLE public.posts (id uuid PRIMARY KEY, title text NOT NULL);
GRANT SELECT ON public.posts TO anon, authenticated;
Default Privileges
Wrong -- grant per-table, forget on future tables:
GRANT SELECT ON posts TO anon;
Right -- set default privileges in initial setup migration:
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT ON TABLES TO anon, authenticated;
Fallback Observability
Wrong -- silent fallback hides production bug:
if (error) return DEFAULT_POSTS;
Right -- log at ERROR level when fallback activates:
if (error) {
console.error('[TABLE_FALLBACK] posts query failed:', error.message);
return DEFAULT_POSTS;
}
Health Endpoints
Wrong -- health check only tests connectivity:
app.get('/health', async () => {
await supabase.from('posts').select('count');
return { status: 'healthy' };
});
Right -- check actual data access:
app.get('/health', async () => {
const { data, error } = await supabase.from('posts').select('id').limit(1);
if (error) return { status: 'degraded', reason: error.message };
return { status: 'healthy' };
});