Supabase
Postgres database patterns for building content transformation pipelines with Row Level Security, type generation, and migration workflows.
Schema Conventions
- Use snake_case for table and column names
- Include
created_at and updated_at timestamps on every table
- Use UUID primary keys
- Define foreign key relationships explicitly
Row Level Security (RLS)
- Enable RLS on every table
- Create policies based on authenticated user roles
- Use service role key for server-side operations (bypasses RLS)
- Test policies by querying as different user roles
Migration Workflow
- Create a migration SQL file with descriptive name
- Test locally against a development database
- Merge to main — CI applies the migration automatically
- Regenerate TypeScript types from the updated schema
Type Generation
Generate TypeScript types directly from the database schema. This ensures type safety between your database and application code without manually maintaining interfaces.